The visitors opened the scoring at McDiarmid Park through John Sutton, and Andrew Driver gave them a 2-1 half-time advantage after Rowan Vine had levelled the scores.
Steve MacLean equalised after the break in a match filled with goalscoring opportunities and questionable defending.
Within the first five minutes, Alan Mannus was forced into a save from Gordon Smith.
Hearts would soon be rewarded for their quick start, taking the lead in the 14th minute. Driver's floated free-kick found Sutton who headed down and past Mannus from the left side of the six-yard box.
The lead, however, was short-lived. Two minutes later both Kevin McHattie and Marius Zaliukas failed to make proper connection with a cross from the right. The latter's attempted swipe resulted in the ball being hooked straight up into the air and onto the toe of Vine to tap home from two yards out.
Hearts should have answered four minutes after conceding their advantage but Smith floated the ball over the crossbar under pressure from David McCracken.
It was a good chance but not as clear-cut as the opportunity Peter Pawlett squandered on 27 minutes. The winger, on loan from Aberdeen, broke through the offside trap to run onto Vine's reverse through ball with only McDonald to beat. The Hearts keeper did well in parrying the shot, but with the whole goal to aim at Pawlett should have given him no chance.
Difficulty in dealing with routine balls into the box hurt St Johnstone again in the 38th minute. This time it was Ryan McGowan's long throw from the left that found Sutton's head in the penalty area where the goalscorer turned provider by flicking on for Driver to sweep home.
The lead should have been made comfortable five minutes after the restart. Driver's cross from the left was headed back by Sutton who found his strike partner alone in the centre of the penalty area. Smith elected to shoot first time and drove his volley wide of the post.
Pawlett then wasted another chance in what was almost a carbon copy of his first half opportunity. This time it was Murray Davidson springing the winger beyond the offside trap, but the same outcome occurred as McDonald parried away the shot.
From the ensuing corner, MacLean saw his hooked effort from close range cleared off the line, but the hosts would not be denied for long.
Callum Davidson's switched long ball hit Murray Davidson perfectly in stride on the right wing. The midfielder, streaking into the box, rolled the ball across goal for MacLean to tap in.
With the momentum fully behind his team, St Johnstone boss Steve Lomas introduced Gregory Tade for Pawlett and the striker almost had an instant impact.
On defensive duties Sutton inadvertently diverted the ball past his defence for Tade to run onto. MacDonald came out to block but lost the battle as Tade stumbled past the keeper and tried to prod the ball past the covering Hearts defenders. After a couple of ricochets it fell kindly for MacLean to finish into the empty net before Ryan McGowan appeared from nowhere to hoof clear.