Adam Rooney’s 89th-minute winner secured Aberdeen’s spot in the League Cup semi-finals.
The Irishman came off the bench to score the only goal to knock out St Johnstone.
The game was tense and cagey throughout but it was a superb finish from Rooney to put the Dons into the final four.
It was a typical meeting between the two as both teams struggled to create opportunities, not dissimilar to the league opener between the two.
It was a joyous end to a night that started with a blow for the Dons.
Derek McInnes was forced into a late change just minutes before kick-off.
Niall McGinn and Rooney were due to be replaced by Sunday’s super-subs Wes Burns and Jayden Stockley.
But after Jonny Hayes was ruled out with a hamstring injury late on, McGinn was restored to the line-up.
And it didn’t take long for Aberdeen to fashion a half-chance.
After five minutes, Graeme Shinnie fired on goal after Stockley’s cross but his shot was deflected behind for a corner.
James Maddison, making his first start at Pittodrie, was booked just a minute later for a foul on Murray Davidson.
The resulting free-kick was easily cleared away with Danny Swanson blazing over the rebound.
Games between these teams have typically been tight in recent years and tonight was no exception.
The Dons started slowly but started to turn up the pressure after the 10-minute mark.
Joe Shaughnessy was shown a yellow card for a foul on Maddison to prevent a quick break.
And as the Dons started to build momentum, Shay Logan fired wide from 25 yards.
The visitors were committing men back in numbers to try and stem the flow.
In a rare foray forward for the visitors, Steven MacLean clipped the ball over the crossbar from 20 yards.
There were few opportunities for the Dons to exploit despite looking the side more likely to score.
Maddison tried to wriggle through but saw his effort blocked and McGinn fired well over from distance.
Burns was a livewire up front but could not get in behind a deep St Johnstone defence.
And just after the half-hour mark, Swanson had a great chance for the visitors.
He cut in from the left and fizzed a low effort on goal but Joe Lewis was alert to hold it well.
Shinnie was added to the referee’s notebook minutes later for a last-gasp challenge on Joe Gormley.
He screamed at Logan for being caught out of position, re-emphasising how any mistake could prove crucial in such a tight game.
The latter stages of the first half were sloppy as both teams bypassed the midfield.
But with just two minutes left in the half, Aberdeen produced a move of quality.
A fast break set McGinn away and he was able to whip a dangerous ball into the middle.
Burns was on the prowl in the box but he could only stab it wide on the stretch.
There was no injury time at the end of a remarkably quiet first half.
The old adage of a game swinging on a piece of magic or a mistake seemed fitting with so few chances.
After 47 minutes, Swanson was once again able to break down the left but his curled effort landed wide of Lewis’ goal.
St Johnstone made a change just a minute later, with Michael Coulson replacing Gormley.
The visitors did not help matters and seemed intent on breaking up the play, with the referee’s whistle a regular sound.
Paul Paton was booked after 51 minutes after another foul and from the resulting free-kick, Maddison floated the ball wide.
If there was one player going to get a goal, it looked like Swanson.
The 29-year-old fizzed a vicious 25-yard effort just over the top, with Joe Lewis looking concerned for a moment.
The visitors showed ambition that was lacking in the first half and were on top.
But just after the hour, Aberdeen had their first real chance of the half.
Kenny McLean stole free from the visiting defence at a corner but his close-range effort flew over.
The home crowd were incensed with some inconsistent decision-making from referee Craig Thomson.
But after 68 minutes, it was the visiting supporters who were complaining about an officiating call.
Swanson surged forward and freed David Wotherspoon behind the Dons defence.
But after slotting the ball beyond Lewis, the linesman called the play back with a late offside flag.
With 18 minutes remaining, McInnes rolled the dice by bringing on Rooney and Peter Pawlett for Stockley and Burns.
The impressive Swanson was withdrawn four minutes later for Liam Craig as the visitors shuffled their pack.
With the Dons pressing high up the pitch, the visiting defence was suddenly under pressure.
Aand Davidson was the next man in the book as he chopped Maddison down just as Rooney threatened.
McGinn was the next victim of the Saints’ naughty challenges, winning a free-kick 25 yards out.
McLean lashed it at goal but Zander Clark was behind it all the way.
Brian Easton forced to Lewis into a stop as his cross swerved towards goal.
Just as the game appeared destined for extra time, Wotherspoon once more thought he might have won it.
After Andrew Considine fouled Wotherspoon 32 yards, the 26-year-old fired the free-kick on goal.
And it took an outstanding save from Lewis to push it onto the post with just four minutes left.
But there was still more drama yet to come.
After some good work down the left from Shinnie, he whipped a teasing ball into the box.
And Rooney’s deft backward header flew into the bottom-right corner to beat Clark, sending Pittodrie ballistic.
Pawlett presented McGinn with a chance to clinch the game in stoppage time but he fired tamely at the keeper.
But it didn’t matter as that was the last action with a roar from the home crowd as the final whistle blew to secure a heart-stopping victory.