Sone Aluko gave Aberdeen the lead with a superb solo effort in the first half before Liam Craig equalised with 14 minutes to go after Jamie Langfield had spilled a Dave Mackay cross.
However an 83rd minute penalty from Lee Miller gave the Dons their first win since the middle of September.
Aluko and Michael Paton started for the Dons in place of suspended duo Maurice Ross and Chris Maguire, while Peter Pawlett replaced the injured Fraser Fyvie.
St Johnstone, looking for their third win on the trot, also shuffled their pack with Jonatan Johansson and Chris Millar preferred to strikers Kenny Deuchar and Filipe Morais who both dropped to the bench.
The home side started brightly and could have opened the scoring within two minutes when Aluko pounced on a searching pass from Charlie Mulgrew but the Nigerian international shot into the side-netting from an acute angle.
However the visitors created an opening of their own three minutes later with a fine passing move that ended with Finnish striker Johansson firing a left-footed shot inches wide.
The Saints were forced to make an early change after nine minutes with Steven Anderson coming on for Irish central defender Graham Gartland who appeared to injure his shoulder after landing awkwardly.
Aberdeen took the lead after 15 minutes with a fine counter-attacking move expertly finished by Aluko. Pawlett showed excellent pace and strength to shrug off Danny Grainger before finding Aluko who dribbled past two defenders before slotting the ball past Graeme Smith.
Pawlett was thriving on his return to the starting Aberdeen XI and he showed an abdance of speed once again to out-sprint the visiting defence before unleashing a left-foot shot that was clawed away by Smith.
Andrew Considine was shown the first yellow card of the day when he cynically chopped down Samuel after 31 minutes.
Smith was called into action soon after to thwart Pawlett with the St Johnstone goalkeeper keeping his composure to hold a powerful effort.
Langfield pulled off a superb near-post save to deny Samuel after 42 minutes to ensure the Dons went into half-time a goal in front.
Goalscorer Aluko, who took a knock in the first half, was replaced at half-time by Darren Mackie with the Saints also making a change with Deuchar being introduced at the expense of the ineffective Johansson.
The Aberdeen substitute almost made an immediate impact when he earned a yard of space in the box with a terrific piece of skill before smashing a shot from a tight angle off the post.
Jerel Ifil almost doubled Aberdeen’s side lead with a neat shot on the turn that was excellently tipped over the bar by Smith after 54 minutes.
The former Swindon defender was then the hero at the other end just before the hour mark when he cleared a Deuchar header that had beaten Langfield off the line.
Ifil came to the rescue for Aberdeen again after 73 minutes when a Langfield punch fell kindly into the path of former Don Kevin Rutkiewicz who lobbed the ball over the stranded keeper but the Aberdeen defender again headed the ball clear.
However St Johnstone’s mounting pressure paid off when they got back on level terms with only 14 minutes to go. Jamie Langfield dropped a hanging cross from David Mackay under pressure from Deuchar and Liam Craig pounced on the loose ball to roll the ball into the unguarded net. The Aberdeen goalkeeper was convinced he had been fouled in the lead up to the goal and was booked for his protestations.
However the Dons had an opportunity to regain the lead when Miller was bundled over in the box by Grainger after 83 minutes and the Dons striker kept his composure to drill the spot-kick home himself.
Paton could have put the icing on the cake with a ferocious 30-yard shot that rebounded back off the crossbar in the dying stages.