It had for the most part been an even match between the two SPL sides. Motherwell had led through Jamie Murphy's superb strike with 10 minutes remaining.
Johnny Hayes scampered away down the left in the opening seconds, before his low cross was cleared by Fraser Kerr with McGinn ready to pounce behind him.
Hayes had Lee Hollis under pressure within a minute. After his corner was cleared to the edge of the area, the winger fired in a shot that the keeper could only parry, before the danger was cleared.
Joe Shaughnessy was the first name into referee Willie Collum's notebook for a mistimed challenge on Murphy, and that led to a lengthy spell of pressure on the home goal, which saw Jamie Langfield push a Chris Humphrey strike over the crossbar.
Motherwell threatened moments later when Henrik Ojamaa bullied his way past Mark Reynolds, only to place his shot wide of Langfield's left-hand post.
The scores remained level at the interval, and it took a while for the action to heat up in the second half at a freezing Pittodrie.
The home side came close to a fortuitous opener after 57 minutes when Shaughnessy's low cross to the near post spun off Kerr and onto the Motherwell man's own post.
Langfield provided some light relief when he took a swing at Shaughnessy's awkwardly-bouncing pass-back and succeeded only in slicing the ball straight up in the air. The Dons keeper caught the ball on the way down, as the Motherwell attack waited to pounce.
Well were presented with the chance to shoot from a free-kick when Rae brought down Keith Lasley, but Tom Hateley's effort flew over Langfield's crossbar from 20 yards.
Motherwell were convinced they should have had a penalty after 74 minutes, Ojamaa's shot seemingly blocked by the arm of Anderson, but Collum waved play-on despite the veracity of the protests.
It was going to take something special to open the scoring, and it was Murphy who provided it. The Motherwell attacker took the ball on the edge of the penalty area and rifled a superb 20-yard strike beyond the helpless Langfield.
But Aberdeen bounced back, and McGinn snuck in at the back post to head an Andrew Considine cross past Hollis just as the game was about to tick into injury time.