Chris Willock scored the winner as QPR came from behind to beat fellow strugglers Rotherham 2-1 and climb out of the Championship relegation zone.
Tom Eaves' early goal gave the division's bottom side hope of a first away win since November 2022.
But the hosts turned it around in the second half, with Paul Smyth equalising before Willock's 75th-minute strike secured three priceless points.
This match seemed like the perfect opportunity for inconsistent but improving Rangers to climb out of the bottom three, where they had been languishing since September.
However, they started poorly, with goalkeeper Asmir Begovic saving from Sam Clucas and Femi Seriki also going close for the visitors when he sent an effort wide, before Eaves netted in the seventh minute.
After Ilias Chair's diagonal ball was cut out and Sam Nombe's flick left the QPR defence flat-footed, Eaves got away from Jake Clarke-Salter and looped his finish over Begovic.
Rotherham continued to have the upper hand, with Peter Kioso's shot bringing another save from Begovic before visiting keeper Viktor Johansson was finally called into action.
Johansson kept out Michael Frey's header from Jack Colback's cross, and Steve Cook's header from a ball in by Chair, who also had an effort saved by the Swede.
Johansson produced another save shortly before half-time, again from a Cook header following a Chair cross.
And half-time substitute Smyth hauled Rangers level after 61 minutes, collecting Willock's pass and firing across Johansson and into the far corner of the net.
Chair had another shot saved and later crossed for Jimmy Dunne to head wide before setting up the winner.
Willock collected Chair's pass and thumped an unstoppable shot beyond Johansson from near the edge of the penalty area.
The victory moved Rangers above Stoke, whose 2-1 defeat at Cardiff saw them slide into the relegation zone.
It also continued a steady improvement since the appointment of boss Marti Cifuentes in October.
The west London side have now lost just one of their past seven matches but face a daunting trip to face leaders Leicester next Saturday.