Dundee striker Steve Lovell hit a last minute goal to earn his side maximum points at Pittodrie.
Steve Lovell crashed home the winner in the final minute
The young Dons had the best of the first half and were rewarded with an early goal from Richard Foster.
But the visitors stepped up a gear after the interval and drew level after 73 minutes when Steven Milne scored from close range.
Aberdeen's Paul Sheerin's hit the post late in the game and Lovell had the final say with a powerful finish.
Dundee created the first opportunity after six minutes when Chris Hegarty picked out Lovell, allowing the striker to attempt a lob but, with with Dons keeper Ryan Esson stranded, the ball sailed over the bar.
Aberdeen broke up the field from Esson's goal-kick and scored the opener when John found space in between Lee Mair and Brent Sancho and went through one on one with Derek Soutar.
The rookie keeper did well to save at the striker's feet twice, but was eventually beaten after the ball broke to Foster, who tapped in from close range.
Dundee tried to hit back instantly and went close through Hegarty, but his shot flashed wide from 12 yards.
Aberdeen had another opportunity after 20 minutes, but Stewart could not find the target from Sheerin's cross.
Soutar was less than convincing, parrying Paul Sheerin's tame shot from the edge of the area, but this time no Dons players were on hand to punish his mistake.
The Dundee goalkeeper had another scare when his Aberdeen namesake, Kevin Soutar, hit a speculative snapshot that had him scrambling across his goal after the ball took an awkward bounce.
The visitors had a great chance to equalise two minutes after the interval when Milne rounded Esson. However, he dragged the ball too far, allowing Scott Morrison to track back and clear his trundling shot.
Kneissl should have equalised in the 71st minute, but blazed the ball over the bar from 12 yards after being picked out by Milne with a cross from the right.
Dundee finally got the equaliser two minutes later through Milne. Brady's cross from the left found Kneissl, who nodded on towards Mair.
The defender, who is out of contract in the summer, then prodded a pass towards Milne, who was standing two yards out and thrashed the ball past Esson.
Kneissl was then denied by Esson, who produced a wonderful save to pluck the ball from the right corner after the German met Milne's cross with a powerful header.
Sheerin went agonisingly close with a header in the final stages, but saw his effort come back off the crossbar.
But Lovell struck in the dying seconds to give Dundee the winner, with a blistering finish after being played in by Barry Smith.
Aberdeen: Esson, McCulloch, Considine, Heikkinen, Morrison, Foster, Souter, Sheerin, Clark, Stewart, Hinds. Subs: Hutton, Prunty, Tarditi, Donald, O'Leary.
Dundee: Soutar, Mackay, Sancho, Mair, Hernandez Santos, Hegarty, Smith, Brady, Milne, Lovell, Robb. Subs: Speroni, Kneissl, McNally, Cameron, Jablonski.
Referee: H Dallas