Late goals from Chris Killen and Scott McDonald ensured a return to the top of the SPL table for Celtic.
McDonald is mobbed after scoring a last-minute winner
Fabian Yantorno curled in a sweet long range free-kick to give Gretna a deserved half time lead.
Evan Horwood made an amazing clearance to keep out a McDonald header as Celtic pressed for a way back.
But the home side's stubborn resistance was broken by a looping Killen header on 85 minutes and McDonald pounced to slide in a low winner in injury time.
It was the first meeting between the sides and Gretna will feel hard done by after leading for so long against the out-of-sorts champions.
A scrappy opening at Fir Park was notable only for two early injuries.
Gretna defender Aurelien Collin left on a stretcher after an awkward fall and was replaced by Daniel Grainger.
Celtic's Paul Hartley, playing in an unaccustomed right-back role, went off with a hamstring problem, with John Kennedy coming on.
Celtic appeared rather lethargic after their midweek victory in the Champions League and home keeper Greg Fleming was not troubled in the first half.
Yantorno was the liveliest player in the home ranks, trying his luck from distance on three occasions before finding his range on 37 minutes.
The Uruguayan was tripped 25 yards from goal and dusted himself down to curl a delicious free-kick round the defensive wall and beyond the static Artur Boruc.
Gavin Skelton had a chance to double the advantage soon after but, having nipped in ahead of Gary Caldwell at the near post, his volley flew wide from 10 yards.
Celtic looked more purposeful after the interval and Massimo Donati sliced a shot wide before Killen looped a header on to the roof of the net from a promising position.
McDonald must have thought he had levelled the game on 66 minutes when Fleming missed a dropping cross, allowing Killen to head across goal to his strike partner.
The Australian had a free header from six yards but Horwood came racing back to divert the ball on to his own crossbar and away to safety.
Celtic appeared to have run out of steam but Killen took advantage of some poor defending to claim his first goal for the club.
The New Zealander sent a high header over Fleming after a period of head tennis in the penalty box.
And McDonald gathered an Aiden McGeady shot to turn and slip the ball under Fleming as bottom of the league Gretna were again punished for failing to clear their lines.
Gretna: Fleming, Barr, Innes, Cowan, Collin (Grainger 14), Horwood, Jenkins, Murray, Skelton, Yantorno (Paartalu 81), Grady (McMenamin 64). Subs Not Used: Caig, Graham, McGill, Hogg.
Booked: Murray, Barr, Cowan.
Goal: Yantorno 37.
Celtic: Boruc, Hartley (Kennedy 18), Caldwell, McManus, Naylor, Nakamura, Scott Brown, Donati (Jarosik 80), McGeady, Killen, McDonald, Kennedy (O'Brien 75). Subs Not Used: Mark Brown, O'Dea, Sno, Riordan.
Goals: Killen 86, McDonald 90.
Ref: B Winter