A brilliant first-half volley from Rovers midfielder Iain Williamson looked to have won Saturday's Scottish Cup fifth-round tie at Stark's Park.
And the First Division outfit, 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 just when Raith were ready to celebrate a batting success on the tricky surface, McDonald popped up to force a Pittodrie replay.
Derek Young and Michael Paton came into Mark McGhee's starting line-up, with Zander Diamond dropping to the bench and Fraser Fyvie not involved.
Charlie Mulgrew stepped in at centre-half, with Diamond, just back from injury, not risked on the heavy pitch.
Peter Pawlett and Sone Aluko also returned to the bench after injury.
The hosts restored Stephen Simmons after suspension with Mark Ferry benched. On-loan Dundee United strikers Jonny Russell and Kevin Smith both started.
The match survived a morning pitch inspection after heavy rain but the park was cutting up even in the warm-up.
Raith, however, adjusted quickest and Simmons drove into the side-netting from 18 yards after just two minutes.
Aberdeen, backed by a 3,300-strong away support in a boisterous crowd, sought to find their feet and six minutes later almost led.
Darren Mackie showed great pace to chase down a long kick from Jamie Langfield and only the outstretched hand of David McGurn denied his shot across goal.
But with top-flight experience in their ranks, Rovers quickly re-grouped and Smith, the lone striker supported by Gregory Tade and Russell, turned to pull just wide.
Aberdeen had a fight on their hands as stout defending from Raith, crowding out Young, illustrated their desire.
Young's free-kick was then held by McGurn as the Pittodrie side pushed for the crucial breakthrough.
But, 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 former Dunfermline midfielder Williamson caught the loose ball sweetly to send a glorious left-foot volley from the edge of the area past Langfield.
Aberdeen were shocked and the goal further inspired the Raith rearguard as the likes of man-of-the match Mark Campbell and Grant Murray kept the visitors at bay.
McGurn was also in top form for John McGlynn's men, touching over a looping Mackie effort and then saving Richard Foster's fierce shot.
Wilson, another ex-Dunfermline man, almost added to the Dons' woe when he drove through a crowd of players to force Langfield to save at the second attempt.
Aberdeen craved a quick reply after the break and Paton almost supplied it as his strike through a ruck of bodies drifted a yard past the post.
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.
But the Reds were struggling for openings, their lack of creativity up front only inspiring Raith.
Indeed, the hosts almost doubled their advantage on 68 minutes when a loose ball broke back to Simmons and his side-footed effort looked destined for the bottom corner until Langfield made a fine stop.
Aluko and Wilson went head-to-head as tempers frayed, before Paton weakly headed over an Aluko free-kick on 78 minutes.
But Aberdeen were running out of ideas with McGhee even throwing 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 on 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, before the Dons' blushes were saved in the fifth minute of time added on.
Aluko's ball into the danger area saw Mulgrew swing a leg at it to wrong-foot the home defence and McDonald knocked in from close-range.