Derek McInnes made one change to the side that drew with Inverness as James Maddison made his first start with Wes Burns taking a place on a very strong looking bench.
Maddison went on to put in an outstanding performance. In the first minute, he spread to the ball wide to Logan. There was no room for the right-back to get down the flank so he played the ball back to skipper for the day Shinnie. His through ball looked to pick out Rooney but his pass was just slightly over hit and went harmlessly out of play. A positive start though.
In the third minute, good play by Maddison set Hayes free down the left. His strong run led to the first corner of the game. The corner was won by O'Connor in the air but his header was knocked off the line and the home side scrambled the ball clear. Aberdeen kept up the pressure and Logan's cross was headed behind for a corner which Dundee defended better this time.
Hayes should have been awarded a free kick in the 8th minute when he was fouled by Cammy Kerr but referee McLean gave a goal kick instead. A minute later, Hayes won the third corner of the game. Maddison's ball in was headed back towards goal by Taylor but Darren O'Dea, who had a fine game, was well positioned to clear.
Hayes then stood the ball up for McLean who did well to win a header at the back post but again, Dundee were able to clear.
Despite all the pressure from Aberdeen, it was Dundee who took the lead in the 12th minute. A well worked move saw the ball flicked on by El Bakhtaoui into the path of left-back Kevin Holt who fired a low shot past Lewis from the edge of the area.
Aberdeen to their credit did not panic and slowly worked their way back into the game. After some more pressure, they were rewarded with an equaliser. Maddison picked the ball up on the edge of the area and, after twisting and turning, he fired in a low shot which went under Bain into the net. The keeper should have saved the effort but James got his rewards for being positive.
After 21 minutes, referee McLean booked Kerr for a foul on Hayes after another strong run from the Irish winger though the previous challenge looked more of a foul. A well worked move from the set piece saw Hayes play a low ball to McLean who had a free shot but did not make a proper connection.
On 26 minutes, Dundee hit the Dons on the break after Maddison had lost possession. A superb tackle by Taylor prevented Mark O'Hara from getting the shot away.
A minute later, McLean put over a really good cross which Rooney flicked towards goal but the ball just went wide. Then from another Dons corner, Taylor this time miskicked inside the area. Dundee then broke at pace and it took a very good last ditch tackle by O'Connor to save the day before El Bakhtaoui curled the ball just wide.
A positive run from McGinn in the 32nd minute led to a free-kick in a very dangerous central area 25 yards out. Niall's first attempt hit the wall and his follow up effort cleared the bar. A good opportunity wasted.
Hayes, McGinn and Maddison were all causing the Dundee rearguard problems with their direct running. The referee was also having a problem - working out when they were getting fouled and when they were not.
On 40 minutes, Maddison tackled the right-back Kerr on the halfway line and the Dons had a two on one but the pass from James just went behind Rooney. The Dons were pressing high up the pitch which prevented Dundee from passing out from the back. Referee McLean then booked O'Connor before bringing an intriguing first half to an end.
At the start of the second half, Dundee continued to allow Aberdeen plenty of possession but the Dons almost gave away a goal when a careless pass allowed McGowan a shot at goal but the midfielder put his effort well wide. Maddison then tried his luck from distance after another silky run but he was just off target.
On 49 minutes, Dundee won their first corner of the game but Taylor headed clear. Three minutes later, Dundee captain O'Dea was booked for a foul on Shinnie. The skipper remained in the thick of the action and was unlucky to see a fine effort crash off the bar and then seconds later he was booked after a late tackle. The reaction from the Dundee keeper Scott Bain suggests he got a touch on the Shinnie shot. If he did, it was a fantastic save.
On 55 minutes, Dundee had a free-kick in a good area out wide. The ball over though was way over hit. Both teams were guilty of lacking a bit of quality from set pieces. Some 62 minutes in, Hayes was booked when he appeared to get the ball. Tom Hateley put over a better ball this time but O'Hara headed over. O'Hara then became the sixth booking for a foul on Maddison.
The game went through a very scrappy stage as things became quite tense. In the 65th minute, McGinn threaded a ball through for Maddison and he was one on one with Bain. The Dundee keeper was out quickly though and saved well as the on loan Dons player tried to dink the ball over him. A minute later, Dundee appealed for a penalty when El Bakhtaoui went down in the area. It would have been soft. O'Hara then flashed a shot just over Lewis' bar.
Dundee will have been well pleased to still be in the game at this point and they were beginning to grow in confidence. Aberdeen needed to change something. On 73 minutes, Jayden Stockley replaced Adam Rooney and Niall McGinn was replaced by Wes Burns while a tactical change saw Hayes move over to the right. It was an inspired substitution from the manager. On 76 minutes, Hayes produced a great run and cross and Stockley bulleted a header past Bain. It was the first cross of real quality in the game and it led to a vital goal.
With ten minutes to go, Aberdeen brought on Craig Storie to replace Maddison who got a standing ovation from the 1,725 Aberdeen fans.
The final ten minutes were interesting as Dundee went for a more direct approach - Loy had replaced Hateley - and the Dons had the pace of Burns on the break. O'Connor produced another superbly timed tackle on El Bakhtaoui before Burns was unable to take advantage of a couple of promising opportunities.
With just under five minutes to go, Burns broke forward and into the area. He was tackled by Extebeguren who appeared to get the ball but also the man and a penalty was awarded. With Rooney on the bench, Kenny McLean took the responsibility and although his effort hit the bar it bounced down over the goal line. The Dons fans were able to enjoy the added time as the game was won.
In added time O'Hara was given a second yellow and then a red card.
A deserved scoreline in the end.