The visitors had been leading 2-1 going into the last quarter of an hour with a double from Steffen Wohlfarth coming each side of Michael Ngoo's 49th minute equaliser.
Substitute Jason Holt equalised for the hosts on 79 minutes before an Evangelos Oikonomou own goal gave them the lead 60 seconds later. Ngoo then completed the goal flurry six minutes from time.
The loss sends County to their third successive defeat in the SPL and keeps them trailing rivals Inverness by six points in the race for Europe. The final result was not what the travelling team deserved. They dominated the first half and could have been out of sight before Hearts' late fightback.
Hearts started the brighter, with Brad McKay and Jamie Walker going close, but soon their more experienced and assured opponents settled down, taking the lead in the 22nd minute. Jamie Hamill, making his first start after missing 11 months through injury, was turned too easily by Wohlfarth and the striker blasted the ball into the top corner.
Kevin McHattie hit the post from long range but it was a brief spark in an otherwise poor first-half performance and the visitors finished the half on top, Ivan Sproule seeing a swept shot from inside the area parried by the keeper.
Hearts boss Gary Locke responded to the lacklustre display with a half-time double substitution, introducing attacking midfielders Holt and Arvydas Novikovas, and it had its desired effect within four minutes of the restart.
McHattie swung in a high ball to the edge of the six-yard box and Ngoo was able to climb highest and nod it past Michael Fraser. The parity lasted only five minutes. Under pressure from Sproule, McHattie was only able to clear the ball out for a corner. From the resulting set-piece, Iain Vigurs' inswinging cross found the front post run of Wohlfarth - who headed his side back in front.
With time ticking away County looked in complete control of the game - until it changed when the visitors were unable to properly deal with another cross from the left. This time the ball was cleared only as far as Holt, whose left-footed hook shot from 18 yards found the far corner of the net to level the scores.
A minute later Hearts took an improbable lead. Ngoo received a pass from Holt and slipped in Walker, running in behind the defence. The young winger's awkward effort was edging wide before Oikonomou's desperate attempt at a clearance sent the ball crashing into the back of his own net.
The self-destruction was not finished. Scott Boyd, under pressure from John Sutton and Ngoo, conceded possession to the former whose square-ball to the latter allowed the on-loan Liverpool striker to drive a low shot past Fraser. It doubled his goal tally for the match and ensured Hearts won all three points - an unlikely prospect for much of the contest.
- Sports & Recreation