The match appeared to be heading for a disappointing stalemate, until Mackie’s goal only five minutes from time.
In a Scottish Premier League encounter of few goalscoring opportunities, Mackie’s solitary strike was enough to give the Dons back-to-back victories after their headline-grabbing 4-0 hammering of Hamilton seven days earlier – and sent them top of the table.
Andrew Considine had the ball in the net in the first half for the Pittodrie outfit only for referee Steven McLean to rule his header out for a foul and the home side were left to rue Kevin Rutkiewicz’s costly first-half miss.
St Johnstone’s on-loan West Brom striker Marcus Haber scampered clear down the left to create the game’s first opening but Dons defender Zander Diamond produced a magnificent block on his cross with Sam Parkin poised to pounce.
With the game slowly sparking to life, Saints should have taken the lead in the 17th minute.
Aberdeen goalkeeper Mark Howard failed to hold a high ball in a crowded goalmouth and, when the ball was shuttled back into the danger area, Rutkiewicz screwed his shot wide when the ball fell kindly to him barely six yards out.
Aberdeen finally put pressure on new Saints goalkeeper Peter Enckelman in the 33rd minute but could not find the breakthrough the game needed.
Chris Maguire turned Liam Craig on the flank but saw Michael Duberry clear his low cross from almost under his own crossbar and then Enckelman grabbed the Dons striker’s tame left-foot shot.
Craig sustained a hamstring injury in the move and was replaced by Danny Grainger, who had himself been injured a week previously against Hearts.
Two minutes later the visitors had the ball in the net as Considine headed in Paul Hartley’s whipped free-kick delivery but referee McLean controversially ruled the strike out for a foul in a busy penalty box.
In first-half injury time, it was St Johnstone’s turn to come close as Howard tipped away Parkin’s header from Grainger’s long throw.
In a low-key opening to the second period it was Grainger’s ability to send in long throw-ins that again carved out an opportunity for St Johnstone in the 52nd minute.
The former Dundee United full-back’s delivery reached the middle of the area but the soaring Murray Davidson could not direct his header on target.
Aberdeen forward Peter Pawlett curled a shot past Enckelman’s left-hand post four minutes later before another moment of controversy in the home box.
Rutkiewicz appeared to obstruct Maguire and send him stumbling towards goal as he raced clear of the Saints rearguard but McLean ignored claims for a penalty and awarded a corner instead.
Both sides made double substitutions in forward areas, with Mackie and Scott Vernon being introduced for Aberdeen and Collin Samuel and Scott Dobie coming on for St Johnstone and it proved an inspired move for McGhee as Mackie earned his side three points.
Sone Aluko drove over from 25 yards with five minutes remaining before setting up the winner seconds later.
The winger blocked Maybury’s clearance and kept the ball in play on the left touchline before finding Mackie in the box and the replacement’s first-time shot appeared to take a deflection on its way into Enckelman’s bottom left-hand corner.