Circumstances always seemed likely to conspire against St Mirren. The Paisley team's shock victory over Celtic in last month's League Cup semi-final served notice that this meeting, at the last-eight stage of the Scottish Cup, would require the full attention of Neil Lennon and his players. A midweek league loss at Motherwell also placed Celtic in that dangerous mood of seeking an immediate recovery.

Celtic duly secured the passage to the last four that it was reasonable to anticipate before kick-off. Yet on the balance of play, few could have grudged St Mirren a replay; they harried and hassled Celtic, with Lee Mair passing up a glorious stoppage-time chance to claim a draw. It proved the culmination of a fiercely competitive, tight cup tie in which the St Mirren goalkeeper, Craig Samson, was never under siege.

Lennon's attention now turns towards Wednesday's trip to Turin, for a Champions League exercise against Juventus which may seem futile – the Italians are three goals to the good – but offers a final opportunity of the season for Celtic to showcase their ability on European football's grandest stage.

"This gives us a psychological lift going into Wednesday," Lennon said. "It also keeps our season going. We have won the game, won the tie, at a difficult place. If we had lost today, that could have been our season over competitively. I want us to keep going. I don't want things to peter out."

St Mirren will, of course, be wounded by their cup exit but they at least have the positive backdrop of a League Cup final, against Hearts, on 17 March. They are also all but guaranteed Scottish Premier League survival already.

One of the most interesting aspects of Celtic's closing weeks of this campaign will surround the form of their young winger, James Forrest. Injury has beset Forrest's season to the extent that he needs an extended run in the first team to restore confidence and fitness. Forrest duly played a part in Celtic's first two goals here and was, in fact, the game's most creative individual.

Ledley converted the first goal, from close range, after Forrest's cross. St Mirren offered a sharp response although that owed plenty to chaos in the Celtic defence as Emilio Izaguirre headed past the static Fraser Forster instead of clearing; Esmaël Goncalves charged in to head the hosts level. Izaguirre had, in fact, spurned two opportunities properly to defend. "It was a comedy of errors," Lennon later admitted.

Celtic were soon back in front, thereby partly saving their Honduran defender's blushes. After a quick short-corner routine, Forrest's perfect ball to the back post found Stokes. The Irishman, who is playing for his Celtic future between now and the summer, headed past Samson. Stokes could have settled Celtic nerves, 10 minutes after the restart. Instead, the ex-Hibernian striker found the side netting with an angled attempt.

St Mirren's finest spell of the tie was to follow. They were almost handed, literally, parity as Forster spilled a routine David Van Zanten cross. Thomas Rogne, who endured an otherwise troubled afternoon and was later substituted, saved his goalkeeper's blushes by booting clear of danger.

This proved a rare, quiet day at work for Gary Hooper. The Celtic forward, though, should have capitalised on a Mair error as he raced through on goal. Hooper's fierce attempt was brilliantly tipped on to the crossbar by Samson, with Forrest pulling the rebound wide.

Goncalves could not properly connect with a Graham Carey pass, 12 minutes from time, as St Mirren sought salvation. They were subsequently denied precisely that both by a spectacular Forster save from a Carey free-kick and Mair's profligacy. In the latter case, St Mirren could have won a penalty had Mair held on to the ball rather than offer an immediate shot at goal.