Raith Rovers beat Partick Thistle on penalties at the end of a pulsating two-legged tie to reach the Scottish Premiership play-off final.
Rovers held a 2-1 lead going into the game at Stark's Park, but Thistle stunned the hosts with a 2-1 victory of their own to take the play-off tussle to extra time.
There were no further goals in the extra 30 minutes and the home side then prevailed 4-3 in the shootout.
They will now face either Ross County or St Johnstone for a chance to play in the top tier of Scottish football next season.
David Mitchell saved Rovers skipper Scott Brown's penalty to give the visitors the early advantage in the shootout, but Jack McMillan fired wide and then Ricco Diack hit the post to give Lewis Vaughan the chance to win it for the home side.
Mitchell got his fingertips to the striker's spot-kick but could not keep it out, the successful penalty sparking jubilant celebrations - including from former Prime Minister Gordon Brown - at Stark's Park.
The Kirkcaldy club will face Ross County or St Johnstone - whichever team finishes 11th in the Premiership table on Sunday - over two legs on Thursday, 23 May and Sunday, 26 May.
Thistle boss Kris Doolan shuffled his midfield pack for the second leg and it paid early dividends as Blair Alston - who was recalled after scoring his side's goal in Tuesday’s first game - poked in a free-kick that deflected off Scott Brown and wrong-footed Kevin Dabrowkski.
Rovers had moved the ball slickly at Firhill in the first leg but lacked fluency in front of the own fans until just before the half-hour mark when Ross Matthews put them back ahead on aggregate.
Left-back Liam Dick clipped a beautiful ball across the penalty area and right-back Matthews - a midfielder playing out of position in defence - headed beyond Mitchell for his first goal of the season.
Thistle roared back though and Scott Robinson's deflected shot flew over from close range just before the break.
In added time at the end of the first half, Brian Graham flicked the ball on to Robinson and he set up Alston to finish at the second attempt after a fine initial save by Mitchell.
There were no more goals, but only because Harry Milne was denied by two superb fingertip saves from home keeper Dabrowski while Rovers captain Brown produced an incredible double goal-line clearance from a glancing Aaron Muirhead header then a thumping strike from Euan O'Reilly.
Rovers, who pushed champions Dundee United most of the season in the Championship, held their nerve despite falling behind in the shootout and are now two games from a return to the top flight for the first time since 1997.