Aberdeen's Niall McGinn continued his predatory form this season as he headed home a last-minute equaliser to earn Aberdeen a William Hill Scottish Cup fourth round replay against Motherwell.

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.

Aberdeen's injury problems have been well-publicised in recent weeks, but they were boosted by the return of Gavin Rae after he had missed the past two games with a hamstring injury. Johnny Hayes also made it into the side despite suffering a similar injury in the midweek league defeat against Inverness.

Rae took the place of Chris Clark, who had been taken to hospital for an X-ray after the midweek game.

Motherwell, meanwhile, were forced into two changes from the side that had beaten Dundee United. Lee Hollis replaced Darren Randolph in goal after the Irishman was handed a retrospective two-game ban following a clash with Calum Paterson in the 0-0 draw with Hearts last Saturday.

Shaun Hutchinson missed out through injury, to be replaced by Fraser Kerr, while an unforced third change saw Stevie Hammell return from an ankle injury to replace Zaine Francis-Angol in defence.

Hayes showed no signs of his injury as he scampered away down the left in the opening seconds, before his low cross was cleared by Kerr with the in-form Niall McGinn ready to pounce behind him.

Hayes had 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.

The lively Hayes threatened again after 11 minutes when his 25-yard strike took a deflection which left Hollis wrong-footed, the ball seeming to come of the keeper's knee before swirling away for a corner.

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.

Hayes was sent clear by Shaughnessy just before the half-hour, but blazed high and wide of the target.

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.

A minute later, Hayes popped up again, crossing to the near post where McGinn could only flick his header towards the back post, and Russell Anderson just could not latch onto it.

At the other end, 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.