Marcus Fraser netted a late winner as St Mirren fought back to clinch a 2-1 comeback victory over Inverness to reach the Scottish Cup quarter-finals.
Their reward is a tie with the winner of Saturday’s match between Kilmarnock or Montrose, with a place in the semi-finals at stake.
Nikolay Todorov’s sixth goal in five games had given the visitors the lead and Kristian Dennis equalised shortly afterwards before Fraser’s 89th-minute effort sent the hosts through.
St Mirren made three changes from the team beaten by Motherwell as Ethan Erhahon, Ryan Flynn and Lee Erwin were replaced by Jon Obika, Dennis and Kyle McAllister.
The visitors lined up in almost identical fashion to the side that had drawn with Queen of the South with Sean Welsh replacing Roddy MacGregor.
After a positive start from Inverness, it was the home team who had the first chance but Ilkay Durmus’ acrobatic effort went well over.
Jamie McGrath then sent a shot off target after a mistake from Scott Allardice before the visitors struck back with a Daniel Mackay drive that was well saved by Jak Alnwick.
The Inverness forward was then denied again by the goalkeeper before St Mirren looked for a penalty from a McAllister shot that appeared to come off an Inverness arm.
From the loose ball, Dennis was denied by Mark Ridgers in the visitors’ goal.
Inverness then enjoyed a period of sustained pressure but could not make the breakthrough.
Welsh sent a free-kick well over the top before Todorov was denied by another terrific save from Alwnick.
In between those two Inverness chances, Dennis was unlucky to see his effort blocked by Brad McKay.
Both teams struck the woodwork before half-time with Scott Allan’s driven effort was pushed on to the St Mirren post by the terrific Alnwick, while another Dennis effort bounced off David Carson before striking the crossbar.
It was the visitors who finally broke the deadlock early in the second half. Allan’s corner travelled all the way to the back post where Todorov volleyed the ball beyond the goalkeeper.
Within two minutes, however, St Mirren were level as McGrath played in Dennis, who took a touch before unleashing a ferocious left-footed shot.
St Mirren struck the crossbar for a second time not long after through Durmus, with Dennis sending the rebound wide.
But the hosts were not done yet and their winner came one minute from time when Obika struck the post and – when Brandon Mason turned in the loose ball – Fraser pounced from a few yards out to seal passage to the last eight.