Grant Brebner was the hero with a fantastic strike in injury-time as Dundee United continued their recovery and completed a wonderful week for caretaker manager Gordon Chisholm.
The Terrors recorded their third win in a row and looked as if they are set to play their way out of trouble.
Hearts, however, could consider themselves a shade unlucky as they contributed well to an excellent game - one in which both teams had a number of chances to score.
After a spirited start from United, including several attacks, the visitors created their first chance in the 15th minute and it resulted in a strong shout from the Hearts bench for a penalty.
Lee Miller overpowered Paul Ritchie at the edge of the box and tried to edge his way into the area, before falling easily to the ground under pressure from Mark Wilson. Infuriated by the non-award, Jambos manager John Robertson was subsequently warned by the referee for his verbal attack on the fourth official.
Hearts continued to create chances and Miller's header from Jamie McAllister's centre forced a full-length diving save from Tony Bullock, before Steve Pressley headed just over from a corner.
Despite this, the Tangerines still went forward in numbers and Stuart Duff was almost the man to open the scoring on the half hour, but two superb blocks from Jason Thomson prevented the opener.
Eventually United took the lead in the 37th minute when a deep Wilson cross was missed by Thomson, giving Robson the opportunity to control the ball and whip it in from ten yards.
But the Jambos hit back two minutes later, and a curling McAllister cross was watched by the United defence, still sleeping after their goal, allowing Miller to nod the ball down into the far corner.
A triple save from Scotland keeper Craig Gordon in the 56th minute prevented United from taking the lead. He clawed out a Robson corner, parried a Brebner volley and pushed away a Garry Kenneth header to frustrate the Tangerine support.
As the game swung like a pendulum, Kenneth smacked the bar with a close-range header from Robson's free-kick before, two minutes into injury-time, Brebner scored that wonderful goal - a curling 20-yard shot that flew over Gordon and into the top corner.