Scott Vernon's injury-time goal gave Aberdeen a dramatic Scottish League Cup victory against Dunfermline.
The Pars dominated the first half and almost took the lead when Andrew Barrowman's shot struck the post.
Winger Joe Cardle came close with two efforts at the Aberdeen goal in the second half.
The Dons had rarely threatened but substitute Vernon 's tap-in from Niall McGinn's cross secured victory for Craig Brown's side.
Aberdeen join Celtic, Dundee United, Hearts, Inverness, Rangers, St Johnstone and St Mirren in the fourth-round draw.
First Division Dunfermline countered from an early Dons corner and goalkeeper Jamie Langfield had to be alert to block Stephen Husband's shot.
The Pars competed well against Aberdeen at East End Park
The Pars were the more positive team and Cardle's cross was almost headed into his own net by Aberdeen's Mark Reynolds, with the defender relieved to see the ball hit the side netting.
A snapshot by Ryan Wallace flashed across the face of Langfield's goal and, moments later, the goalkeeper clutched the ball before the forward could get his toe to a through pass.
Referee John Beaton adjudged Gavin Rae's foul on Cardle to have taken place outside the area, much to Dunfermline's dismay.
Aberdeen had their first chance when McGinn latched on to Cammy Smith's pass but the winger lacked the composure needed to convert and fired over as Gallacher committed himself.
Barrowman's shot on the turn struck the goal frame and the half-time whistle soon gave the Dons respite.
Cardle drove at Aberdeen's defence early in the second half and fired narrowly wide as the Scottish Premier League visitors continued to live a charmed life.
And Cardle threatened again with Langfield touching the winger's shot onto the bar before smothering the ball.
Vernon replaced Jonny Hayes and the substitute missed the target with two efforts in the final 13 minutes of regulation time.
But Vernon did convert from close range to prevent extra-time and secure Aberdeen's place in the quarter-finals.
Dunfermline manager Jim Jefferies:
"We're down and we're disappointed.
"That was a magnificent performance. Sometimes in football you need a wee rub of the ground and we didn't get it.
"We had shots on target that came back off the post. Langfield made three great saves, our goalkeeper hardly had a save to make.
"Playing like that, we'll be up there contesting what we're trying to do; put a challenge in for promotion."
Aberdeen manager Craig Brown:
"We did live dangerously. If I were Jim Jefferies, I'd be very disappointed. His team did enough to at least get into extra-time.