St Mirren earned a hard-fought Scottish Premiership win over Aberdeen - but it was not enough to prevent their place in the relegation play-off being confirmed.
The Paisley side knew they needed to better Kilmarnock's result to keep alive their hopes of reaching 10th place and safety.
And, although goals in each half by Richard King and Killian Phillips earned them victory, Kilmarnock's late win over Dundee means they cannot now be caught.
St Mirren now face a two-legged play-off final against either Dunfermline Athletic or Partick Thistle, who drew 1-1 in the first leg of their semi-final.
Interim manager Craig McLeish had stressed the need for a reaction after Saturday's 3-0 defeat to Kilmarnock had caused his side to slip into the play-off position.
And St Mirren showed attacking intent and energy from the start here.
Killian Phillips had the first real sight of goal, dragging a low shot wide, and it was the visitors who found a breakthrough against former manager Stephen Robinson.
Mark O'Hara picked out the run of Jacob Devaney and he flashed the ball across goal, where King turned it into the net.
Robinson brought on Lyall Cameron and Jack Milne at the break and the former almost made an immediate impact when he played in Toyosi Olusanya. But the striker's first touch allowed Alex Gogic to make a last-gasp tackle.
Aberdeen continued to push for an equaliser, but St Mirren were resolute and then took their chance to double the lead when it came.
Gogic struck the woodwork with a powerful free-kick and St Mirren reacted quickest, Mika Mandron playing the ball across goal for Phillips to score.
Aberdeen tried to muster a comeback, and substitute Graeme Shinnie crashed a shot of the bar, but St Mirren saw it out for an ultimately meaningless win.