Two late goals gave QPR their first win in 13 matches – and only their second at home since October last year.
After Lyndon Dykes put the hosts ahead, Ryan Mmaee’s third goal in his past six appearances brought Stoke level.
Stoke’s Enda Stevens was sent off early in the second half but Wouter Burger put the Potters ahead before Dykes netted his second of the night.
Ben Pearson’s last-minute own goal was the stroke of luck struggling Rangers desperately needed, and Chris Willock added a fourth in stoppage time.
Before kick-off, QPR paid tribute to club legend Terry Venables, with rousing applause for the former England boss who died this week.
Venables was a popular player at Loftus Road and during a four-year spell as manager guided Rangers to an FA Cup final, promotion to the top flight and then a fifth-placed finish which saw the club qualify for Europe.
QPR’s current plight is a far cry from those heady days, but current boss Martí Cifuentes will at least take some encouragement from their relative improvement since his recent appointment.
His first win came in the Spaniard’s fourth match at the helm – a run which has included two draws.
Rangers took the lead after 11 minutes, when Dykes scored from the spot after Stevens was adjudged to have fouled Steve Cook while trying to prevent him from reaching Paul Smyth’s cross.
However, they missed two glorious chances to double their lead – and then conceded an equaliser a minute before half-time.
After Pearson made a mess of trying to intercept Ilias Chair’s pass, the ball bounced off Elijah Dixon-Bonner to Smyth, who was denied at point-blank range by keeper Jack Bonham.
Another defensive mishap, this time by Ciaran Clark, who presented the ball straight to Dykes, gifted the Scotland striker an opportunity but he shot straight at Bonham.
Immediately after that let-off for Stoke, they broke forward and keeper Asmir Begovic tipped away Tyrese Campbell’s effort after the forward found himself through on goal.
From the resulting corner by Bae Jun-Ho, Mmaee fired into the bottom corner after his first shot had been blocked.
When Stevens was sent off eight minutes after the interval, the tide seemed to be turning in QPR’s favour.
The defender pulled back Smyth near the edge of the penalty area and was shown a second yellow card.
But six minutes later, Stoke went ahead when Burger collected Mmaee’s pass near the edge of the penalty area and sent a left-footed strike beyond Begovic and in off the post.
Rangers responded, with Chair shooting against the post before Dykes hauled them level in the 79th minute.
Willock’s cross was cleared as far as Dykes, who controlled the ball on his chest before shooting low into the bottom corner.
Great work on the left by substitute Ziyad Larkeche led to the all-important goal which put Rangers ahead.
Larkeche fought ferociously for the ball before the Frenchman’s low cross was poked into his own net by Pearson.
And in the dying moments, Willock’s low strike beat Bonham at his near post.
QPR: Begovic, Kakay (Cannon 62), Cook, Dunne (Clarke-Salter 73), Paal, Colback (Larkeche 88), Field (Kelman 73), Dixon-Bonner, Chair, Smyth (Willock 62), Dykes.
Subs not used: Archer, Drewe, Richards, Duke-McKenna.