The visitors, who went into the game unbeaten, took the lead in the 22nd minute through Gavin Reilly who controlled Dan Carmichael’s cross from the right before slamming the ball past Steve Simonsen in the home goal.
Rangers were level just five minutes later when Marius Zaliukas’ looping header drifted into the net after Doonhamers keeper Zander Clark had saved Nicky Clark’s initial shot.
Queen of the South were back in front in the 36th minute with Zaliukas going from hero to villain after he lost possession in his own half to allow the visitors to break through Reilly and he fed Ian Russell who netted with a good finish from 10 yards.
Zaliukas was replaced by David Templeton at the interval and Templeton made an immediate impact as he equalised in the 46th minute, cutting inside and unleashing a 20-yard shot with his left foot following good work by Lewis Macleod and Kris Boyd.
Rangers then went ahead for the first time in the 64th minute when Bilel Mohsni’s diving header from Nicky Law’s corner deflected in off a defender.
Derek Lyle and Lewis Kidd then both went close for Queens but they were unable to mount a sustained comeback.
And substitute Kenny Miller, back from a hamstring injury, sealed the win for Rangers with his first touch with four minutes remaining, racing on to Boyd’s knock down from Lee McCulloch’s long punt forward to score.