Derek McInnes pulled off the proverbial managerial masterstroke as his double substitution secured a priceless win for Aberdeen.
Staring a fourth draw of the season in the face, the Dons boss sent on Jayden Stockley and Wes Burns with 16 minutes remaining and the former scored within three minutes while the latter won a game-clinching penalty.
It was all Aberdeen deserved to start a huge week in the perfect manner with St Johnstone in the Betfred Cup on Thursday and Rangers next Saturday.
They had to achieve their victory the hard way as they went behind against the run of play in 13 minutes.
It was a great Dundee move with Faisal El Bakhtaoui starting it all when he eased away from Ash Taylor on the halfway line and sent Paul McGowan racing towards to the Aberdeen box.
The ball was worked wide to Danny Williams then back inside for McGowan who threaded a good ball into the area for Nick Ross who cleverly laid it off to Kevin Holt and he thundered a left-foot shot past Joe Lewis.
It was a shock to Aberdeen’s system as they had looked comfortable until that point. However, it only took six minutes to draw level even if it was a moment to forget for Dundee keeper Scott Bain.
It was fantastic play by Maddison as he twisted away from Tom Hateley outside the Dundee area then worked the ball on to his left foot.
The Dundee defenders seemed to back off and Maddison drove a low shot towards the left corner which squirmed under Bain before finding the net.
It was a clear error, but Bain made up for his misjudgement nine minutes into the second half with a quite magnificent save.
Aberdeen captain Graeme Shinnie robbed Ross 25 yards out and hammered a terrific left-foot shot which the keeper somehow got his fingertips to and pushed it on to the crossbar.
The one-time Aberdeen player also stood up brilliantly to prevent Maddison from scoring a second goal in 66 minutes although the loanee from Norwich really should have scored.
Maddison was in acres of space as he took a pass from Niall McGinn just outside the box and had a clear one-on-one with Bain.
However, a clumsy first touch allowed the keeper to narrow the angle and he made a fine block.
Even although these chances were the best of the second period, Aberdeen were not as dominant or fluent as they had been in the first period.
Dundee were sharper and looked more dangerous with El Bakhtaoui a constant menace to Taylor and Anthony O’Connor.
However, other than a Mark O’Hara shot which rose over the bar in 68 minutes the Dens Park side failed to really trouble Joe Lewis.
Aberdeen needed inspiration and the manager provided it by sending on Stockley and Burns for Adam Rooney and McGinn, both of whom made sure of a much-needed victory.
O’Connor started the move that led to the crucial second goal with a terrific cross-field pass for Johnny Hayes who was hugging the right touchline.
With one burst of electric pace, he left Kevin Holt for dead as he raced down the flank and hit a wonderful right-footed cross into a perfect area.
Stockley could not have wished for a better delivery and he powered a header into the top right corner.
It was effectively the match-winner but the Dons made absolutely sure when they won a penalty with just two minutes remaining.
Burns used his pace to burst clear of Julen Extabeguren on the left side of the box, forcing the Spaniard into a lunging challenge and while he touched the ball he clearly took out the player and Steven McLean was perfectly placed to award the spot kick.
Kenny McLean took the responsibility and smashed the penalty off the underside of the crossbar.
Mark O’Hara was sent off in stoppage time for a second yellow card offence.
DUNDEE: Bain, Kerr, Extabeguren, O’Dea, Holt, Hateley (Loy 86), McGowan, O’Hara, Ross (Duffy 81), Williams (Wighton 69), El Bakhtaoui. Not used: Mitchell, Vincent, Low, Gadzhalov.
ABERDEEN: Lewis, Logan, Taylor, O’Connor, Considine, McGinn (Burns 74), McLean, Shinnie, Hayes, Maddison (Storie 83), Rooney (Stockley 74). Not used: Alexander, Reynolds, Pawlett, Storey.
Referee: Steven McLean