Dundee 0 Partick Thistle 1
Kris Doolan scored a second-half winner for Partick Thistle against Dundee as the Jags confirmed their fight for Ladbrokes Premiership survival will go to a play-off final with Livingston.
The Maryhill men went into the last game of the season two points ahead of bottom side Ross County and knowing victory would secure their top-flight status for a while longer at least.
Alan Archibald's men returned to the dressing room after a goalless first half to discover County were a goal to the good at St Johnstone which had the Jags, with their inferior goal difference to the Dingwall side, staring at the prospect of automatic relegation.
However, in the 62nd-minute substitute Doolan, who had only recently replaced Ryan Edwards, scored a typical poacher's goal from inside the box to earn a 1-0 win, although Saints did their bit too by levelling late against County.
Thistle will travel to Liv on Thursday with the return game in Glasgow next Sunday.
Dundee fans were unhappy at the end of the game but they were safe from the threat of relegation and boss Neil McCann was able to give first starts to 19-year-old keeper Calum Ferrie and defender Daniel Jefferies with Genseric Kusunga and Roarie Deacon returning.
For Thistle, Steven Lawless and Miles Storey came in for Doolan and Chris Erskine, who watched from the bench as the visitors almost took an early lead.
However, Adam Barton's header from a Storey cross in the sixth minute brought a great finger-tip save from Ferrie, who then confidently punched clear the subsequent corner.
The Taysiders looked the most likely to get the breakthrough.
There was a penalty claim in the 25th minute when Dundee defender Cameron Kerr was bundled to the ground in a challenge by Storey but referee Steven McLean gave an infringement the other way.
Five minutes later a left-footed drive from Paul McGowan was parried clear by Maryhill keeper Tomas Cerny, and soon afterwards the Dundee skipper was replaced by Randy Wolters after picking up an injury.
It was at that point Thistle took over and just before the interval Barton failed to connect with Edwards' right-wing cross just eight yards from goal and when the ball fell loose, Storey dragged his shot wide.
Minutes after the break, following a corner from substitute Blair Spittal - who had replaced Storey for the start of the second half - Ferrie made another fine save from Danny Devine's header with the home side surviving the corner.
Doolan replaced Edwards in the 55th minute as Archibald reshuffled and the substitution paid off in dramatic style when Lawless played in the striker with a clever pass and the Jags' talisman slipped the ball past Ferrie to change the complexion of the afternoon.
However, there was still work to do for the visitors as Dundee threatened in the tense final stages, with Cerny making a fine save at his near post from a Wolters drive.
But the Maryhill side held out and after the Staggies slipped up, they now have a two-legged chance to retain their top-flight status.