James Grady scored in the final minute of the final game to hand Gretna an amazing victory that clinched promotion and consigned Ross County to the drop.
James Grady (right) scored a double against Ross County
Michael Gardyne blasted County into the lead from the edge of the box.
Nicky Deverdics replied four minutes later from close range and Grady broke clear to fire Gretna ahead.
Deiarmuid O'Carroll bundled an equaliser, but Grady broke clear to fire Gretna ahead and deny St Johnstone promotion in a dramatic finish.
By that time, County had already gone down after Airdrie beat Queen of the South.
Gretna had been forced to win their final game after squandering a 12-point lead in Division One.
And Grady had been preferred to David Graham up front for Gretna with the team going into the final day leading the league by a point struggling to score goals in recent weeks.
David Nicholls also returned from suspension to replace the injured Steven Hogg in the Gretna midfield.
David Irons led Gretna from the dugout at Victoria Park
Mark McCulloch was back in the County defence following his ban, while the returning Martin Scott and Hugh Robertson had to make do with places on the bench.
It was County who broke the deadlock after 30 minutes, Gardyne hammering the ball into the top left-hand corner from 20 yards.
But Gretna drew level four minutes later when Grady's flick from a Nicholls free-kick was saved by Craig Samson and Deverdics scrambled the ball home.
And it looked like the title was heading to Gretna when Nicholls' flick-on sent Grady clear and the veteran striker slipped the ball through the advancing goalkeeper's legs.
However, it was level again four minutes into the second half when a Gardyne cross was headed on by Don Cowie and O'Carroll bundled in the equaliser.
The drama was not over yet and David Graham set up Grady to score and send Gretna to the SPL for the first time in their history with their third title in a row.
Ross County: Samson, McCulloch, Moore, Dowie, Keddie, Adams (Gunn 87), Gardyne, O'Carroll, Shields (Higgins 65), Cowie, Morgan (Scott 46).
Subs Not Used: Tomie, Robertson.
Booked: Moore, Keddie, Dowie.
Goals: Gardyne 30, O'Carroll 49.
Gretna: Malkowski, Cowan, Skelton, Nicholls (Paarpalu 59), Canning, Grainger, McGill (Baldacchino 74), O'Neil, McMenamin (Graham 59), Grady, Deverdics.
Subs Not Used: Macfarlane, Fleming.
Goals: Deverdics 34, Grady 42, 90.
Ref: I Brines