An extra-time header from Sam Cosgrove helped Aberdeen fight back from a goal down at Dens Park against Scottish Championship side Dundee and book their place in the quarter-finals of the Betfred Cup.
The Reds were on the brink of being on the end of a huge upset but were spared the embarrassment when Andy Considine's 91st-minute goal cancelled out Danny Johnson's first-half penalty.
The Dee were by far the better team up until extra time, and manager James McPake will feel hard done by.
On the other hand, the result comes at a crucial time for Derek McInnes and Aberdeen who were convincingly knocked out of Europe by Croatian outfit HNK Rijeka last Thursday.
The Dons will now travel to the capital to face Heart of Midlothian next month and will be looking to reach the final of the competition for the second season running.
Story of the match
Aberdeen had failed to score in their previous three games, and the events of the first half did little to suggest that they would do so in this game.
A key theme of Derek McInnes' game plan was to find striker Sam Cosgrove will long balls from the back. However the service into their star striker was extremely poor, and Dundee centre-halves Jordan Foster and Jordan McGhee were able to handle the English forward well.
The visitors reluctance to play out from the back seriously frustrated the 2,000+ Aberdeen fans who made the short trip down the A90, and two minutes before half time their anger was vented further.
Dundee right back Cammy Kerr fired a free-kick into the area and Forster was clattered by Andy Considine, leaving referee Willie Collum with no choice but to point to the penalty spot.
Danny Johnson stepped up and Dons skipper Joe Lewis the wrong way to give his team a deserved first-half lead.
Aberdeen continued to create little by the way of attacking openings after the break, and it was only after the introduction of teenage midfielder Dean Campbell, winger Connor McLennan and former Manchester United striker James Wilson from the bench, that the Premiership side were able to get their foot on the ball a lot more.
James McPake decided to bring on Andrew Nelson up front in place of goalscorer Danny Johnson, who had been causing the Dons defensive pair of Scott McKenna and Considine all sorts of problems.
With the game entering its final stages, it looked increasingly likely that Dundee were on the verge of scoring the biggest shock of the Betfred Cup so far.
However, in the first minute of the additional four, defender Considine tapped home from close range after Dee keeper Jack Hamilton had done well to save a header from Aberdeen full-back Greig Leigh.
The visitors were extremely fortunate to force the game into extra time, and manager McInnes' delight on the touchline was clear to see.
Dundee, on the other hand, appeared to be disheartened by the late equaliser and failed to maintain their intensity and work ethic over the next 30 minutes.
Cosgrove grabs the headlines once again
Aberdeen's performance over the entire duration of the game was messy and seemed to lack any flow or structure, but they did produce one real moment of quality with two minutes of the first half of extra-time remaining.
Greig Leigh and Scott McKenna combined well down the Aberdeen left, and the former's cross was brilliantly headed home by Sam Cosgrove, who took his tally to nine goals in eight appearances in all competitions in the early part of the season.
Dundee were right to feel aggrieved as the final whistle blew, as they had more than showed their credentials as a solid, organised team, which should give them a decent chance of returning to the Premiership next season.
Derek McInnes has been the subject of a lot of criticism for his choice of style and tactics from large sections of the Aberdeen support, and he will be fully aware of the improvements that need to be made if he is to get all the fans onside again.
Takeaways from the match
Dundee effective with pressing
Despite the result, Dundee boss James McPake will be delighted with the fact that his team were able to restrict the visitors to very few chances. The home side managed to press high and get right in the face of the likes of Scott McKenna, Shay Logan and Greig Leigh, which in turn forced them to look long, completely bypassing their own midfield.
Striker Danny Johnson was a catalyst for the Dundee press, and as well as calmly slotting away the penalty he had lots of joy in his tussles with the Aberdeen defence.
However keeping that level of intensity for 120 minutes is extremely difficult, and gaps began to appear in between Dundee's line in the game's final stages.
Man of the match
In a poor game of football, there were very few players who stood out, but 16-year old midfielder Finlay Robertson was outstanding for the home side. His composure and care of the ball for someone of that age was excellent, and if he can perform to anywhere near that level in future matches then there will be no shortage of suitors coming to watch him at Dens Park.