Late goals from Chris Killen and Scott McDonald spared Celtic's blushes as they snatched victory at Fir Park after Gretna had led for most of the match.
Celtic came into the game on the back of three successive wins and knowing that another would see them move back to the top of the SPL, but, with five minutes of the match remaining, a victory looked unlikely.
Gordon Strachan fielded a new-look line-up with Paul Hartley moved to right-back.
But Hartley's opportunity to shine in defence was short-lived as he sustained a hamstring injury in the opening stages and was replaced by John Kennedy with just 18 minutes gone.
Gretna had their own injury problems to worry about after Aurelien Collin was stretchered off early and was replaced by Danny Grainger.
Celtic had the better of the early possession but it was Gretna who took an unexpected lead on 37 minutes from a Fabian Yantorno free-kick.
His effort took a slight deflection off the wall and left Artur Boruc stumped.
Less than a minute later and with Celtic still reeling, Gretna had the opportunity to add to their tally but Gavin Skelton flicked his effort just over the crossbar.
Leading their first ever league encounter against the Old Firm giants, Gretna left the field at half-time to an ovation from their fans.
Celtic upped their pace in the second half but found themselves up against a resolute Gretna defence.
Killen sent his early attempt from 12 yards out high over the crossbar, while Craig Barr performed heroics for Gretna clearing dangerous balls on several occasions.
Gretna were lucky to keep 11 men on the pitch when Paul Murray landed a hefty challenge on McDonald, but he escaped with a yellow card from referee Brian Winter.
The champions continued to pepper the Gretna goal with shots but Gary Caldwell - carrying a knee injury sustained early in the half - was denied by a Barr clearance, before Killen again missed the target with a header.
But Gretna's hearts were broken four minutes from the end when Killen scored his first goal for Celtic with a flicked header which found its way just inside the post.
Then McDonald ruined the fairytale when he beat the offside trap to give Celtic victory with a dramatic 90th minute winner.