Dundee edged an astonishing eight-goal, winner-takes-all title decider against Queen's Park to clinch promotion back to the Scottish Premiership.
Second-half strikes from Lyall Cameron and Luke McCowan got Gary Bowyer's men over the line, but only after a scarcely-believable encounter that was already 3-3 after a manic first half.
McCowan's wonderful individual effort clinched the title at the first attempt for Dundee, while Queen's will have to go through the play-offs to secure a third straight promotion.
Queen's Park, having at one point looked like going up, finish third and will face Partick Thistle at Firhill on Tuesday in the first leg of the play-off quarter-final.
But up until Dundee's fifth goal, these sides delivered an epic conclusion to a Championship season which went to the final day with nine of the 10 teams not knowing what division they would be playing in next term.
The drama started when Alex Jakubiak gave Dundee a third-minute lead, but centre-back Charlie Fox levelled with one of the goals of the season, before Connor Shields smashed Queen's ahead two minutes later.
Lee Ashcroft clobbered in an equaliser for Dundee, before a strange 17-minute spell without a goal.
But the drama restarted in earnest when Dundee's Zach Robinson scrappily forced the ball in, only for Fox to plant a header past Adam Legzdins to make it 3-3 in first-half stoppage time.
Queen's Park - seeking the victory needed to end a 65-year top-flight absence - went close to edging in front again after the break, but Dundee goalkeeper Adam Legzdins pushed away Shields' powerful effort.
And then Cameron, the homegrown hero, latched on to Jakubiak's flick to finish neatly past Calum Ferrie to put Dundee in the driving seat once more.
At that point there was still 35 minutes left, but as both sides started to feel the effects of a frantic match, Dundee retreated slightly, knowing they only needed a draw to get back to the top flight.
But in the end they had the more clinical tough anyway, as McCowan bobbed and weaved his way into the box before curling a wonderful effort into the corner to spark jubilant scenes among the Dundee fans behind the goal.
More to follow.
Line-ups
Queen's Park
Formation 4-2-3-1
1Ferrie
2Oakley4Kilday5Fox3Robson
8Thomson42Boateng
11Thomas21Savoury10McPake
29Shields
1Ferrie2Oakley4Kilday5Fox3Robson8ThomsonSubstituted forDavidsonat 77'minutes42Boateng11ThomasSubstituted forHealyat 76'minutes21Savoury10McPakeSubstituted forJarrettat 64'minutes29ShieldsSubstitutes
7Longridge9Henderson12Davidson14Moore17Heraghty22Healy25Bannon27Jarrett66EzeDundee
Formation 4-4-2
1Legzdins
15Mulligan5Sweeney14Ashcroft3Marshall
17McCowan34Maguire25Cameron11Hannant
7Jakubiak16Robinson
1Legzdins15Mulligan5Sweeney14AshcroftBooked at 63mins3MarshallSubstituted forKerrat 83'minutes17McCowan34Maguire25Cameron11HannantSubstituted forWilliamsonat 45'minutes7JakubiakBooked at 75minsSubstituted forByrneat 89'minutes16RobinsonSubstituted forThomasat 76'minutesSubstitutes
2Kerr8Byrne9Thomas18McMullan21Lawlor22Williamson28Fisher31Clampin42ReedyLive Text
Match ends, Queen's Park 3, Dundee 5.
Second Half ends, Queen's Park 3, Dundee 5.
Foul by Kwame Thomas (Dundee).
Marcel Oakley (Queen's Park) wins a free kick in the defensive half.
Substitution, Dundee. Shaun Byrne replaces Alex Jakubiak.
Foul by Cammy Kerr (Dundee).
Aaron Healy (Queen's Park) wins a free kick on the right wing.
Luke McCowan (Dundee) wins a free kick in the defensive half.
Foul by Tommy Robson (Queen's Park).
Substitution, Dundee. Cammy Kerr replaces Jordan Marshall.
Goal! Queen's Park 3, Dundee 5. Luke McCowan (Dundee) left footed shot from outside the box to the bottom left corner. Assisted by Lyall Cameron.
Attempt missed. Luke McCowan (Dundee) left footed shot from the centre of the box is close, but misses to the left.
Attempt missed. Ryan Sweeney (Dundee) header from the right side of the six yard box is too high following a corner.
Corner, Dundee. Conceded by Calum Ferrie.
Attempt saved. Ben Williamson (Dundee) left footed shot from the centre of the box is saved in the bottom left corner.
Attempt saved. Kwame Thomas (Dundee) left footed shot from the centre of the box is saved in the top left corner.
Substitution, Queen's Park. Jake Davidson replaces Jack Thomson.
Substitution, Queen's Park. Aaron Healy replaces Dom Thomas.
Substitution, Dundee. Kwame Thomas replaces Zach Robinson.
Alex Jakubiak (Dundee) is shown the yellow card for a bad foul.