Summer signing Juanma scored after four minutes and that was how it stayed until after the break, when the teams scored three goals apiece.
The Jambos extended their lead through Jamie Walker before Simon Lappin pulled a goal back for Saints, only for Callum Paterson to advance from defence to restore the two-goal lead.
Two goals in four minutes then saw St Johnstone pull level but there was still time for one more twist as Sam Nicholson pounced 10 minutes from time to secure the points for the Edinburgh side.
The home supporters were given something to cheer before the kick-off when owner Ann Budge unfurled the Championship title flag.
Juanma, signed from Greek Superleague team Kalloni, took advantage of a slip from Saints defender Brad McKay once the game got underway to advance into the penalty area and slot the ball through the legs of goalkeeper Allan Mannus.
Saints manager Tommy Wright was forced into an early change as captain Chris Millar was forced off, with Scott Brown coming on to replace him.
Nicholson then cleared off the line after John Sutton got on the end of Lappin’s left wing cross and headed goalwards.
Hearts winger Nicholson was in action at the other end of the pitch in the second half as he was brought down in the box by Mannus after Juanma had played the ball through to him, with the goalkeeper subsequently booked.
A woeful spot-kick from Osman Sow was saved by Mannus but the ball came off his foot and Walker was first to the rebound and smash home (52).
Saints refused to crumble though and pulled a goal back four minutes later when the home defence failed to deal with Joe Shaughnessy’s long throw into the penalty area.
Keeper Neil Alexander flapped at the ball and Lappin gratefully converted from close range.
But the Jambos regained their two-goal advantage soon afterwards, Paterson heading the ball on near the halfway line before running through and slotting home after Walker had played him in with a precise through ball.
St Johnstone looked to have clawed their way back into the game as they netted twice in quick succession, Sutton’s glancing header finding the bottom corner with Alexander rooted to the spot.
Graham Cummins then made it 3-3 when he converted a deflected cross-shot from Scott Brown but a seventh goal was to prove crucial.
With 10 minutes left on the clock, Nicholson scored with a deft touch from six yards after latching onto a right wing cross from Paterson as Hearts took all three points to continue their positive run of form from last season.