Gretna 1 Rangers 2
Goals from Barry Ferguson and Daniel Cousin proved sufficient to gather all three points at Fir Park and give the Gers some breathing space over arch-rivals Celtic.
Walter Smith's side attacked from the start. Charlie Adam had an early chance but directed his effort straight at Tony Caig when he should have done better.
Steven Naismith then caught the Gretna defence napping as he nipped in ahead of Caig but the angle was too tight and he could only find the side-netting.
Naismith was clearly in the mood as he tried to catch Caig off-guard from outside the area but the ball slipped a couple of yards wide.
Chris Burke then played in Ferguson who made a superb late run but pulled his shot just wide of the target as Gretna continued to live dangerously.
The home side were given some hope when Allan McGregor failed to deal with a cross from Fabian Yantorno but Paul Murray's final effort lacked conviction and McGregor recovered to save.
Murray had another chance after 28 minutes after a great lay-off by Kenny Deuchar but his shot flew well wide.
But Gretna were forced into a change two minutes later when Abdul Osman went off with a back injury and was replaced by Mickael Buscher.
A slip by Carlos Cuellar ten minutes before the break gave Deuchar a great opportunity but he shot against the legs of McGregor with Rangers stretched at the back.
Rangers hit back and a fantastic run from Burke almost brought a goal but he clipped his shot inches wide of Caig's post.
It took a terrific save from the goalkeeper to deny Adam two minutes before half-time as he leapt spectacularly to get a hand to a shot which was bound for the top corner of his net.
It was going to take something special to beat Caig and it arrived on the stroke of half-time. Ferguson pounced on a flick from Naismith to score with a stunning 16-yard volley.
But Gretna equalised 44 seconds after the restart when Deuchar met Craig Barr's cross to head a wonderful goal past McGregor.
Rangers stormed back and Ferguson was denied by the boot of Caig and his follow-up shot found only the side-netting.
The league leaders felt they should have had a penalty when Naismith was challenged by Aurelien Collin but referee Iain Brines waved play on.
Caig then made a comfortable save to keep out a long-range free-kick from Adam as Rangers looked for the winner.
But Cousin struck with 16 minutes left to put Rangers back in front. He raced onto a pass from substitute Jean-Claude Darcheville before rounding Caig and firing home.
Gavin Skelton had a late chance to equalise after Deuchar cut the ball back but his shot clipped a defender and just cleared the crossbar.