Goals from Ryan Stevenson and John Sutton gave Hearts fans some much-needed cheer as they ended their five-match losing streak.
Stevenson struck in the 32nd minute following a counter-attack and Sutton ensured Hearts moved into 10th place in the Clydesdale Bank Premier League, six points behind sixth-placed Hibernian with three games left until the split.
Hearts could have had more, with Michael Ngoo alone having more than half a dozen decent chances, while St Johnstone also created a number of opportunities, especially in a frantic first half. Both sides had goals disallowed.
Loading article content
The victory will have come as a huge relief for caretaker manager Gary Locke on a day when the board attempted to reassure supporters after the apparently financially stricken Vladimir Romanov resigned from the board of UBIG, the club's majority shareholder.
Fans looking for an escape from off-field concerns got one with an incredibly open first half which began with St Johnstone threatening twice inside two minutes.
Mehdi Abeid was inches away from connecting with Rowan Vine's cross and the pair soon linked up on the break, with the latter forcing Jamie MacDonald into a decent block.
Sutton just missed the top corner with a header and he had the ball in the net in the 12th minute but was flagged offside after bundling home Darren Barr's low cross.
Saints went back on the attack and Murray Davidson side-footed Liam Craig's cutback towards the corner but MacDonald got down well.
Sutton soon had another chance when Mehdi Taouil flicked the ball through but Alan Mannus was off his line quickly to block and MacDonald saved from Steven MacLean.
The game continued to rage from end to end as typified by the opening goal.
Taouil took a quick free-kick on the edge of his box and Sutton managed to get the ball wide to Arvydas Novikovas to leave Saints outnumbered.
The Lithuanian winger played a low cross towards Ngoo but Mannus was again out to foil the Liverpool loan striker. However, the ball broke for Stevenson to drill home from 18 yards.
Ngoo twice broke down the left soon after but Mannus saved his first effort and the tall striker then curled just wide.
Steve Lomas brought on Gregory Tade for Abeid in the 40th minute and the forward was immediately involved, setting up Craig to fire home, although the flag was up before the midfielder shot, and then getting his own strike away to force MacDonald into a diving save.
There was still time for Ngoo to have three more decent efforts before the break, with his closest attempt foiled by Callum Davidson as he stumbled towards goal after skipping past Mannus.
St Johnstone, with Steven Anderson on for Frazer Wright, had the first chance of the second half when captain Dave Mackay curled a free-kick on to the roof of the net.
But there was less goalmouth action after the break as Hearts got men behind the ball, although they looked a threat on the break and Ngoo flashed a shot wide after a Sutton flick-on.
There were soon chances at both ends following free-kicks, with Murray Davidson heading just wide before Ngoo sliced past the post.
Tade almost levelled in the 74th minute when he headed Mackay's cross past MacDonald but Andy Webster hooked the ball off the line.
But Hearts sealed the points in the 83rd minute. Ngoo brushed off Anderson in the right side of the penalty box and rolled the ball across the goalmouth for Sutton to tap home.
Assistant referee Francis Andrews disallowed his second goal of the game when he ruled the ball out of play just before Mackay crossed for Tade to convert with an overhead kick.