When you're a goal in arrears and the seconds are ticking down on your time in the William Hill Scottish Cup, you need a talisman more than ever.

For Aberdeen, it came in the shape of Niall McGinn, a winger-cum-striker whose last-minute goal – his ninth in Scottish football this season – kept open the home side's cup door.

As referee Willie Collum was considering his post-match shower and fans were dreaming of being inside to escape the freezing conditions, Andrew Considine's cross from the left found McGinn's head and, no matter how much Motherwell goalkeeper Lee Hollis, standing-in for the suspended Darren Randolph, scrambled for the ball, he could not keep it out and parity was restored.

Jamie Murphy's superb strike 10 minutes earlier appeared to have been enough to have taken the visitors into the next round of the competition but in the end, manager Stuart McCall was happy his side remain involved.

"We were without Shaun Hutchinson because of injury," he said, "which left us with two inexperienced centre-backs, Fraser Kerr and Adam Cummins. We were terrific in the second half, with a great goal which probably deserved to win it.

"We were fortunate to survive a frantic opening five minutes, but grew into the game. It was a good team effort and it is pleasing still to be in the hat."

The whirlwind of a start by Aberdeen indicated that their players recognised the importance of this game and the need to offer supporters something tangible to win them over immediately. Inside the opening two minutes they twice came within a whisker of scoring, with Jonny Hayes involved on each occasion.

First, his low cross skimmed off a defender as McGinn raced in at the far post. Then, after Hayes collected the clearance of his own corner kick, his delightful cross found Rory Fallon, whose header allowed Hollis to gain confidence from an outstanding save. Indeed, the goalkeeper's agility was once more in evidence as he changed direction to turn a long-distance Hayes strike past the post, the home side clearly keen to unsettle their opponents.

Motherwell's response, to slow the pace and play the ball to feet, worked for a while and it took Jamie Langfield's touch over the bar from Chris Humphrey's 25-yard strike to prevent the visitors, showing greater composure, from going ahead in the 19th minute.

Meanwhile, any threat from Michael Higdon was contained by Aberdeen captain Russell Anderson who seldom left the Fir Park striker's side.

There was little sign of a goal, however, not even when Tom Hateley was presented with a free-kick opportunity from 25 yards when Gavin Rae felled Keith Lasley, the effort going wide to Langfield's right.

It took until 10 minutes from the end for the deadlock to be broken, Higdon feeding Murphy on the left and, after the Aberdeen defence stood off, allowing him to take the ball along the 18-yard line. His shot beat Langfield to offer the visitors hope of a place in the next round of the competition, but as the referee checked his watch and prepared to bring to a conclusion an uninspiring tussle, the home side grabbed the equaliser as McGinn's header drifted too far for Hollis to reach.

"We should have been a couple of goals up in the opening 15 minutes," said the Northern Ireland international. "Going to Motherwell for the replay won't faze us because our away form has been good and we will take confidence from today.

"As for the equaliser, I was in the right place at the right time. I was delighted to see the ball hit the net."