St Mirren triumphed on penalties to claim a place in the Scottish Communities League Cup semi-final.
Sam Parkin put Danny Lennon's team ahead before a Craig Samson mistake gifted Scott Vernon an equaliser.
Kenny McLean put the away side back in front after a Russell Anderson mistake before Josh Magennis equalised deep in to injury time.
St Mirren were successful with four spot-kicks while Stephen Hughes and Cammy Smith failed for the Dons.
Despite Aberdeen's bright start, it was Lennon's men who took an early lead.
Jamie Langfield could only push a Steven Thompson header onto the crossbar, and the ball fell kindly for Parkin to convert from close range.
The home side should have been level after 12 minutes. Hayes played a delightful back-heel into the path of Niall McGinn. His shot was beaten out by Samson and landed at the feet of Vernon, only for the striker's effort to be deflected over the bar.
They would find an equaliser midway through the first half and it was Vernon who grabbed it, although Samson will be disappointed with his role in the goal.
The visitors cleared a corner to Mark Reynolds on the halfway line, his ball back into the box was missed by Samson. From the penalty spot, Vernon looped a header beyond the stranded goalkeeper and into the net.
The Aberdeen goal was under threat 10 minutes after the leveller. A Magennis foul gave Jim Goodwin the chance to strike a low 20 yard free kick towards the bottom right corner, but Langfield was swiftly across his goal to turn the effort away.
Just after the half hour, McGinn cut in from the left saw his right-footed effort loop up into the air after a massive deflection off Goodwin, leaving Samson grateful to pluck the ball from the air just inches from his line.
It was a much more solid looking Buddies that emerged after the interval, and they showed the steel required to regain their lead.
Anderson saw his clearance blocked on the edge of the area, and McLean sent a superb first time strike beyond Langfield from the corner of the penalty area.
Buddies captain Goodwin became the first name to go into referee Crawford Allan's book when he was penalised for a foul on Magennis, and that would rule him out of the semi-final as he had been booked earlier in the competition.
With 12 minutes left the first change for either side saw Aberdeen introduce the pacy Fraser for Vernon, and five minutes later Cammy Smith replaced Clark Robertson.
The Saints should have sealed their place in the semi-final in the 90th minute, striker Thompson crashing a header off the post from a Teale cross.
The home side's attacking changes paid off in the second minute of injury-time when Magennis, now playing up front, turned home from close range after Samson had parried Smith's low strike.
St Mirren's nerves returned, and early in extra-time Samson gave away a cheap throw from which Hughes found space and cracked a shot off the bar from 15 yards.
The pace of Fraser was a new threat, and he sparked a move after 95 minutes that eventually saw McGinn flash wide of Samson's left-hand post.
Substitute Guy had a golden chance to win in with the last kick of the ball but was adjudged to have dived as he tried to round Langfield, and was instead booked rather than grabbing the headline-grabbing goal.
The game then went to penalties and Samson made the decisive save from Smith's penalty.
Aberdeen manager Craig Brown: "I'm desperately disappointed. I can't fault my side for effort and commitment, but we didn't get the breaks. I thought we would have the psychological advantage after coming from behind twice, but it wasn't to be.
"We should have been 3-0 up after five minutes, but St Mirren took their chances and that is what enabled them to progress.
"We can't allow this to affect our league form. We have to take it on the chin, take a deep breath and make sure we recover at the weekend."
St Mirren manager Danny Lennon: "I'm a very proud man tonight. I thought the boys were like gladiators tonight. They fought right to the end.
"The character the boys showed throughout the game was first-class. To lose the lead in the dying minute of the game was very difficult to take and the boys showed great character to take us over the line and take it to penalties.
"If every game was like that, stadiums would be full across the country. I think both sets of fans were entertained throughout. It was a good game of football to watch."