Adam Rooney scored twice as in-form Aberdeen stretched their unbeaten run to 12 games and drew level with Celtic at the top of the Premiership.
Aberdeen secured the victory manager Derek McInnes had demanded to exert pressure on the defending league champions. The Dons leaked two late goals but still held on for a 4-3 success.
St Johnstone, now without a win in eight matches, gave the visitors cause for anxiety for long spells of the second half. However Aberdeen deserved their win.
Rooney secured an early lead and curled home a deflected but ultimately decisive 77th-minute strike that gave Aberdeen a 4-1 cushion.
Peter Pawlett had given Aberdeen a 2-0 interval advantage but David Wotherspoon provided battling Saints with fresh hope soon after the interval.
Dons substitute Niall McGinn cashed in on an error by former colleague Joe Shaughnessy for the third in the 72nd minute to the relief of travelling fans in a 5,712 crowd, and Rooney's second looked to have killed the game.
But Aberdeen nerves were jangling again in the closing minutes. St Johnstone defender Steven Anderson headed a Liam Craig corner into the net off Rooney, and then goalkeeper Scott Brown could not prevent Tam Scobbie's shot finding the net in the 89th minute.
But the Dons held firm in four minutes of stoppage time to share top spot with a Celtic side on Scottish Cup duty this weekend.
McInnes planned three changes to the Aberdeen starting line-up following the win over Celtic in midweek but Mark Reynolds, who was due to drop to the bench, was hastily pitched in when Andrew Considine was injured in the warm-up.
Home boss Tommy Wright was forced into making five changes to the side which lost a League Cup semi-final to Hibernian, with former Hearts winger Danny Swanson handed his debut in place of Rangers-bound Michael O'Halloran.
The Dons got off to a perfect start in the fifth minute when Rooney rushed in at the back post to slam home a delivery whipped over by right-back Shay Logan.
St Johnstone were denied a leveller by the upright in the 10th minute when Scobbie's powerful drive swept beyond goalkeeper Brown only to crash back into play.
Pawlett then struck with a raking 25-yard free-kick which seemed to take a deflection to wrong-foot Alan Mannus.
Five minutes from the interval Graham Cummins swept past Brown but the Irishman was forced to shoot from the tightest of angles and the ball rolled past the far post.
Scobbie was denied again minutes after the restart when Graeme Shinnie headed his dipping volley off the line.
Wotherspoon reduced the deficit in the 52nd minute when he calmly finished off a flowing move from close range.
Rooney squandered a glorious chance before the hour mark when he curled a 16-yard shot inches wide.
McGinn gave the anxious Dons breathing space in the 72nd minute when he dispossessed Shaughnessy deep in the the penalty area and tapped the ball into an empty net when Simon Church rolled the ball into the six-yard box.
Rooney made it 4-1 with his 18th goal of the season, but rather than coasting to the finish Aberdeen were made to sweat when Anderson and Scobbie threatened to snatch a point from a thriller in Perth.