McDonald (right) saved any more red faces for Aberdeen late on
Aberdeen prevented a Scottish Cup fifth-round shock when Gary McDonald scored in the final seconds to equalise against First Division Raith Rovers.
Dons striker Darren Mackie was denied by a superb David McGurn save before Iain Williamson struck a fine volley after 32 minutes from 20 yards.
McGurn saved from Mackie and Richard Foster while Stephen Simmons forced a Jamie Langfield save at the other end.
McDonald fired home from close range in stoppage time to save the Dons.
It had looked like Mark McGhee might suffer the kind of cup exit that dogged his predecessor as Aberdeen boss, Jimmy Calderwood, until that strike in the fifth minute of stoppage time.
Williamson (left) opened the scoring at Stark's Park
The Kirkcaldy side, winners of the League Cup in 1994, appeared set to become the fifth Scottish Football League side to defeat the Dons in the last four seasons but will now face a replay.
Derek Young and Michael Paton had started for the Scottish Premier League side, with Zander Diamond benched and Fraser Fyvie missing through injury and Peter Pawlett and Sone Aluko returning from their own problems to be among the substitutes.
The first half was an end-to-end affair, with the Dons playing the more controlled football on a terrible pitch that survived a morning inspection but which was cutting up even in the warm-up.
Aberdeen's superior pace was troubling Raith, but it was the home side who threatened first and Simmons drove into the side-netting from 18 yards after just two minutes.
The Dons, backed by a 3,300-strong away support in a boisterous crowd, almost went into the lead six minutes later.
Darren Mackie showed great pace to chase down a long kick from goalkeeper Jamie Langfield and only the outstretched hand of McGurn denied his shot across goal.
But, with top-flight experience in their ranks, Rovers quickly re-grouped and lone striker Kevin Smith turned to pull the ball just wide.
Young's free-kick was then held by McGurn as the Pittodrie side pushed for the crucial breakthrough.
However, in superb style, it was Raith who claimed a dramatic 32nd-minute opener.
Craig Wilson's cross was only partly headed clear by Jerel Ifil and Williamson caught the loose ball sweetly to send a glorious left-footed volley from the edge of the area past Langfield.
Aberdeen were shocked and the goal only sought to further inspire the Rovers rearguard as the likes of Mark Campbell and Grant Murray kept the visitors at bay.
McGurn was also in top form, touching over a looping Mackie effort and then saving Richard Foster's fierce shot.
Former Dunfermline defender Wilson almost added to the Dons' woe when he drove through a crowd of players to force Langfield to save at the second attempt.
Paton almost supplied a reply after the break as his strike through a ruck of bodies drifted a yard past.
Raith's cause was hampered by an injury to Laurie Ellis, who limped off to be replaced by Dougie Hill, but they continued to stick to their task doggedly.
Dons boss Mark McGhee had seen enough and threw on Aluko and Pawlett for Young and Mackie, the latter's substitution not going down well with the travelling support who voiced their displeasure.
Aberdeen were still struggling for openings, their lack of creativity up front only inspiring Raith.
Indeed, it was almost 2-0 after 68 minutes when a loose ball broke back to Simmons, who had returned from suspension for Rovers with Mark Ferry benched, and his sidefooted effort looked destined for the bottom corner until Langfield made a fine stop.
McGhee threw defender Diamond on up front in the closing moments in a desperate bid for the leveller.
Jim Paterson's up and under did end up in the net after 90 minutes, but referee Willie Collum correctly ruled it out for shoving on McGurn, Paton saw another effort deflected just past and Ifil headed at McGurn.
However, Aluko's ball into the danger area saw Charlie Mulgrew swing a leg at it to wrong-foot the home defence and McDonald knocked in from close-range.
Aberdeen manager Mark McGhee: "I think we put everything into it and the attitude was first class.
"To go a goal down was a shock again, but we kept going, although the longer it went the more worried you become.
"I think the psychological thing about losing to these teams weighed on the team.
"Raith Rovers put in a magnificent effort, but I don't think they deserved to beat us.
"If we did not get the late goal, it would have been travesty of justice."
Live text and stats
Saturday, 6 February 2010
02 Wilson yellow card
03 Ellis (Hill 50)
07 Williamson (Ferry 89)
08 Simmons yellow card
09 Smith (Weir 84)
22 Ifil yellow card
08 Kerr (Diamond 87)
14 Young (Aluko 61 yellow card)
10 Mackie (Pawlett 64)
Ref: CollumAtt: 7,045
Attempts on target
Attempts off target
90:00+5:56 The referee blows his whistle to end the game.
90:00+5:36 Mark Campbell takes a shot. Jamie Langfield makes a save.
90:00+5:21 Craig Wilson takes the indirect free kick.
90:00+5:21 Booking Sone Aluko goes into the referee's book for unsporting behaviour.
90:00+5:16 Sone Aluko concedes a free kick for a foul on Craig Wilson.
90:00+4:09 GOAL - Gary McDonald:Raith 1 - 1 Aberdeen Gary McDonald scores a goal from close range to the bottom left corner of the goal. Raith 1-1 Aberdeen.
90:00+3:18 Jerel Ifil takes a shot. Save made by David McGurn.
90:00+2:39 Graham Weir is flagged offside by the assistant referee. Indirect free kick taken by Jamie Langfield.
90:00+0:59 Free kick awarded for an unfair challenge on Graham Weir by Sone Aluko. Mark Campbell restarts play with the free kick.
90:00+0:18 Inswinging corner taken by Michael Paton, Gregory Tade makes a clearance.
89:36 Outswinging corner taken from the left by-line by Charlie Mulgrew, clearance by Mark Campbell.
89:02 Handball by Stephen Simmons. Free kick taken by Jamie Langfield.
88:03 Substitution Mark Ferry comes on in place of Iain Williamson.
87:22 Shot on goal by Jerel Ifil from just inside the area clears the crossbar.
86:42 Substitution (Aberdeen) makes a substitution, with Zander Diamond coming on for Mark Kerr.
83:36 Substitution Kevin Smith leaves the field to be replaced by Graham Weir.
82:38 Jamie Langfield restarts play with the free kick.
82:38 Booking Craig Wilson shown a yellow card.
82:23 Craig Wilson challenges Sone Aluko unfairly and gives away a free kick.
81:27 Booking Jerel Ifil receives a caution for unsporting behaviour.
81:13 Foul by Jerel Ifil on Johnny Russell, free kick awarded. Indirect free kick taken by Grant Murray.
80:16 Corner taken left-footed by Johnny Russell, clearance made by Mark Kerr.
78:44 Booking Stephen Simmons goes into the book for unsporting behaviour.
77:03 Michael Paton takes the inswinging corner, Peter Pawlett produces a header from the edge of the box and misses to the right
of the goal.
75:44 Headed effort from deep inside the area by Michael Paton misses to the right of the goal.
75:26 Free kick awarded for a foul by Mark Campbell on Sone Aluko. Sone Aluko restarts play with the free kick.
74:24 Free kick awarded for an unfair challenge on Sone Aluko by Craig Wilson. Jamie Langfield takes the free kick.
73:47 The official flags Kevin Smith offside. Jamie Langfield restarts play with the free kick.
72:35 Mark Campbell challenges Steven MacLean unfairly and gives away a free kick. Direct free kick taken by James Paterson.
70:17 Free kick awarded for an unfair challenge on Johnny Russell by Richard Foster. Free kick taken by Grant Murray.
68:37 Free kick awarded for a foul by Douglas Hill on Peter Pawlett. Free kick taken by Jamie Langfield.
68:09 Inswinging corner taken left-footed by Johnny Russell, James Paterson makes a clearance.
67:50 Stephen Simmons takes a shot. Save by Jamie Langfield.
64:00 Substitution Peter Pawlett comes on in place of Darren Mackie.
61:44 Unfair challenge on Mark Kerr by Mark Campbell results in a free kick. Indirect free kick taken by Charlie Mulgrew.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.