Aberdeen substitute Scott Vernon snatched a dramatic 93rd-minute winner against Dunfermline to send the Dons into the fourth round of the Scottish Communities Cup.
The tie appeared destined to be heading to extra-time but the marksman bundled in Niall McGinn's teasing delivery with seconds left.
The visitors had been booed off at the interval following a first half dominated by the First Division side.
But after some resolute defending and fine goalkeeping from Jamie Langfield, Aberdeen snatched the win after a more competitive display after the break.
In a bright start to the match, both sides created chances that had their fans off their feet.
McGinn thought he had a clear sight of goal after running onto Jonny Hayes' deflected pass inside the box but Callum Morris made a great block tackle.
The hosts turned defence into attack within the blink of an eye and Stephen Husband had a shot from 15 yards parried by Langfield after Andy Barrowman cleverly dummied Andy Geggan's pass.
The sight of Josh Falkingham harrying and charging down an attempted Clark Robertson clearance was systematic of the Pars' approach to the game as their opponents kept the visitors on their toes.
The industrious Falkingham stabbed a loose ball to Ryan Wallace and the diminutive marksman spun past Robertson before dragging a right-footed shot just wide from inside the penalty area.
Wallace then came within inches of connecting with a teasing Joe Cardle through-ball but the ball bounced into the arms of Langfield.
A wild Gavin Rae swing on a Robertson cross that was sliced hopelessly wide summed up the Pittodrie side's first half.
The Dons survived penalty appeals in the 37th minute when referee John Beaton decided that Rae's trip on Cardle was just outside the box. Cardle took the free-kick but his powerful drive cannoned off the wall.
Aberdeen created their best chance of the half four minutes before the interval when McGinn raced onto Cameron Smith's defence-splitting pass - but the former Celtic player hit a left-footed shot over the bar from close range.
An exciting finish to the first 45 minutes saw Barrowman crack a left-footed shot off the far post after Falkingham's deflected effort fell kindly at his feet.
The Dons made a more encouraging start to the second period but Paul Gallacher easily gathered Hayes' tame effort from close range following a Josh Magennis cross.
Cardle then beat right-back Magennis before curling a right-footed shot just round Langfield's far post from 20 yards.
The lively winger was then denied a speculator goal when Langfield palmed his long-range effort onto the bar.
Cardle was in the thick of the action and his corner caused panic in the goalmouth before the danger was eventually cleared.
Aberdeen brought on captain Russell Anderson at right-back for Magennis and the defender volleyed an Isaac Osbourne corner just wide in the 72nd minute.
Just as the game looked to be heading to extra-time, substitute Vernon bundled in a McGinn cross inside the six-yard box to carry the visitors through.
Why are you making commenting on The Herald only available to subscribers?
It should have been a safe space for informed debate, somewhere for readers to discuss issues around the biggest stories of the day, but all too often the below the line comments on most websites have become bogged down by off-topic discussions and abuse.
heraldscotland.com is tackling this problem by allowing only subscribers to comment.
We are doing this to improve the experience for our loyal readers and we believe it will reduce the ability of trolls and troublemakers, who occasionally find their way onto our site, to abuse our journalists and readers. We also hope it will help the comments section fulfil its promise as a part of Scotland's conversation with itself.
We are lucky at The Herald. We are read by an informed, educated readership who can add their knowledge and insights to our stories.
That is invaluable.
We are making the subscriber-only change to support our valued readers, who tell us they don't want the site cluttered up with irrelevant comments, untruths and abuse.
In the past, the journalist’s job was to collect and distribute information to the audience. Technology means that readers can shape a discussion. We look forward to hearing from you on heraldscotland.com
Comments & Moderation
Readers’ comments: You are personally liable for the content of any comments you upload to this website, so please act responsibly. We do not pre-moderate or monitor readers’ comments appearing on our websites, but we do post-moderate in response to complaints we receive or otherwise when a potential problem comes to our attention. You can make a complaint by using the ‘report this post’ link . We may then apply our discretion under the user terms to amend or delete comments.
Post moderation is undertaken full-time 9am-6pm on weekdays, and on a part-time basis outwith those hours.
Read the rules hereComments are closed on this article