The Pars, who dumped the Dons out of the competition in a quarter-final replay two years ago, looked set to hold out for a replay and were unlucky not to break the deadlock when Andy Kirk’s drive was tipped over the bar by Jamie Langfield.
The Dons, who have made a habit of getting knocked out of competitions by lower league sides in recent seasons, enjoyed a large amount of possession against the First Division side but rarely troubled Kyle Allison in the Dunfermline goal – but it was the visitors who went down late on to an own goal by substitute Neil McGregor.
The Dons will now travel to face St Mirren in the quarter-finals following their late winner.
Left-back Steven Smith was handed a first start for the Dons in place of the injured David McNamee, while Nikola Vujadinovic replaced the absent Andrew Considine.
The Pars brought in Allison for first-choice goalkeeper Chris Smith who was suspended after being sent off against Montrose in the previous round.
Jim McIntyre’s men were without the recently departed Willie Gibson following his move to Crawley and the cup-tied Liam Buchanan, while Nick Phinn dropped to the bench and Andy Dowie missed out altogether.
Aberdeen were given an early scare when Kirk’s angled drive flashed past the post after only six minutes before they were forced to make a change when central midfielder Rob Milsom limped off and was replaced by Derek Young.
It took Aberdeen 15 minutes to carve out their first real opening when Paul Hartley’s clever cross-field pass picked out Scott Vernon, but the striker fired over the bar.
The Pars were looking far from overawed against their top-flight opponents, although the Dons were next to threaten when youngster Ryan Jack showed a neat piece of skill to waltz past Clarke before unleashing a powerful left-footed shot, which was confidently stopped by Allison.
In first-half injury time Vernon headed over from a Smith corner as the Dons ended a relatively uneventful first 45 minutes on top.
Aberdeen continued where they left off after the break with Nick Blackman drilling a shot harmlessly wide from 25 yards.
Blackman had to be replaced after 56 minutes by winger Peter Pawlett after coming off second best in a challenge with Calum Woods.
Aberdeen almost got the goal their dominance deserved after 64 minutes when Young found Chris Maguire in space on the edge of the area and the striker had no hesitation in trying his luck, with his ferocious effort just whistling over the bar.
The visitors created a rare opening four minutes later when Clarke released Kirk but the former Hearts striker was unfortunate to see his thunderous effort tipped over by Langfield.
Maguire appeared fortunate to avoid being punished for kicking out at Alex Keddie before Zander Diamond headed wide in the closing stages.
But deep in injury time Aberdeen won the match when Maguire’s cross into the box was punched by goalkeeper Allison onto the unfortunate McGregor and the ball rebounded into the net to the delight of the home support.