It looked as though it would be a simple night for the Dons when they took the lead in three minutes.
They were two ahead on the half hour and dominated possession to such an extent that there looked no possibility that Ayr could get back in to the game.
However, the complexion changed when Alan Forrest grabbed a goal just before halftime.
And it turned into a nervous second half at times, especially as they could not find a third goal, but in the end they secured their place.
It was the worst possible start for Ayr as Daryll Meggatt diverted the ball into his own net as he tried to clear Wes Burns’s low cross into the six-yard box.
Ayr really should have equalised in five minutes when Forrest was through on Joe Lewis after Mark Reynolds missed Craig McGuffie’s through ball.
Forrest tried to chip the Aberdeen keeper but Lewis got back in time to pluck the ball out of the air.
It was a fleeting moment of excitement for the Ayr fans as Aberdeen proceeded to completely dominate and really should have had the job done early.
Their second goal in 30 minutes was excellent as Shay Logan hit a great ball to the left side of the box where Niall McGinn cleverly steered a right foot shot into the right corner.
Three minutes later Adam Rooney grazed the outside of the left post with a diving header after Graeme Shinnie had offered great supply from the left side.
Then Burns failed to take advantage of two excellent situations, firstly shooting wide in 34 minutes from 12 yards then opting to shoot from a tight angle when Ryan Jack was better placed to score.
That said there was no hint of Ayr getting back into the game when they found a goal in 41 minutes.
They had three attempts before finally getting the ball over the line as Lewis saved Jamie Thomas’s shot, Jamie Adams hit he bar with the rebound and Forrest followed up to bundle the ball home.
The Dons were quickly back in control in the second half but they couldn’t find the third goal that would kill the tie.
Burns tried to take the game by the scruff of the neck but he was unlucky with three chances, hitting the woodwork twice.
He struck the bar with tremendous efforts in 49 and 65 minutes and forced a great save out of Fleming in 62 minutes and Ayr were still in it.
They thought they should have had a penalty in 68 minutes when Adams went down under Andy Considine’s challenge but Alan Muir was close to the incident and felt there was no foul.
Then in the dying moments Nicky Devlin had a chance to force extra time but shot over the bar.
AYR UNITED: Fleming; Devlin, Murphy, Meggatt, Boyle; McGuffie (O’Connell 74), Crawford (Johnston 84), Cairney; Adams, Forrest; Thomas (Gilmour 60)
Not used: Hart, Donald, Rose, Wardrope.
ABERDEEN: Lewis; Logan. O’Connor, Reynolds, Considine; Jack, McLean (McKenna 90+2), Shinnie; McGinn, Rooney (Stockley 60). Burns
Not used: Alexander, Storey, Storie, Wright, Nuttall.
Ref: Alan Muir.