The home side were undone by a Gary Warren double which came either side of Billy McKay's 22nd strike of the season.
Yet Hearts had twice equalised through Jason Holt and a deflected Andy Webster strike - but both times handed the initiative back to their Highland visitors within minutes.
Defeat leaves Hearts in 10th place, seven points away from the top half of the league, while Inverness regained second spot with just their second win in eight games.
Ivan Sproule scored his fifth goal in as many starts to give County the lead, while second-half goals from Richard Brittain and Iain Vigurs completed a fine win.
Saints are now into fourth, level on 40 points with Motherwell, who drop to third, while St Mirren are eight points adrift of the top six with six games until the split.
Rory Fallon's brilliant volley gave the Pittodrie side the lead before Paul Heffernan got Kilmarnock back on terms five minutes before half-time.