Djibril Cisse scored two minutes from time to drag QPR from the canvas and record a hugely important win that could well secure the club's Barclays Premier League status.
Rangers limped through the vast majority of this match and looked set to slip back into the relegation zone, but Cisse stepped off the bench to tap home at the back post after 88 minutes to set the stands at Loftus Road rocking.
Rangers recorded a remarkable 3-2 victory over Liverpool in March with a last minute winner but this result will live much longer in the memory of Rangers fans for its huge significance.
Thanks to West Brom's late comeback to draw 2-2 at Bolton, QPR are now two points above the relegation zone ahead of next weekend's season finale at Manchester City.
A draw at City will be enough to see Rangers survive, although even if they fail to achieve such a difficult task, Bolton will have to win at Stoke to survive.
Rangers fans swamped the pitch after the game in celebration at knowing their team are nearer to survival, but for most of the 90 minutes they barracked their team, who were pitiful performers.
There was no spark in midfield, little threat up front and there were also shaky moments at the back. And all this coming against a Potters team whose season is 55 matches and 10 months old.
Yet, it did not matter in the end for the fans and a jubilant Tony Fernandes thanks to Cisse, who stole in at the back post to convert Anton Ferdinand's flick-on and secure the three points.
Stoke looked the stronger side early on. Despite hitting out at manager Tony Pulis in midweek, Cameron Jerome started in a Stoke team that contained four strikers.
The former Cardiff striker spectacularly failed to reward his manager early on, however, when he latched on to Peter Crouch's knock-down to volley over from 10 yards.
Adel Taarabt proved to be QPR's most lively performer. The Moroccan dazzled the Potters defence with his trickery and also stung Thomas Sorensen's palms with a powerful 25-yard free-kick.
Crouch got on the end of Rory Delap's long throw but Rangers' defence scrambled clear.
The home crowd urged their team on after news of Martin Petrov's opener for Bolton filtered through to Loftus Road, but they failed to respond.
The scrappy play from both teams continued and Barton's weak curler was the only other effort of note inside the first 35 minutes.
Bobby Zamora dispossessed Upson, charged down the right and crossed perfectly for Barton but he nodded straight at Sorensen.
Stoke almost grabbed the lead on two occasions just after the break. Crouch miscued a free header and Ricardo Fuller curled a wicked shot that flew just wide.
The home fans demanded Cisse's introduction and it came after 55 minutes at the expense of Akos Buzsaky.
There was little urgency about Rangers despite the fact they knew they had to win and the home crowd started to get nervous.
Barton threw himself into the path of Huth's volley as Stoke continued to threaten, but QPR earned a good opportunity in the 68th minute when Upson toppled Zamora on the edge of the box.
Taye Taiwo could only drive into the wall, however - his tame shot summing up the hosts' limp performance.
At the other end Paddy Kenny punched the ball away to deny Fuller a free header from eight yards.
The away fans sang "2-0 Bolton, 2-0 Bolton" as it emerged the Trotters had added a second and QPR almost responded to the taunt by taking the lead.
Taiwo crossed brilliantly for Cisse, but Sorensen scrambled across his goal-line to deny the Frenchman.
Hughes threw on Jay Bothroyd and Shaun Wright-Phillips at the death to add some extra impetus and the move worked.
Wright-Phillips' shot deflected wide, leading to a QPR corner. Taarabt's cross was nodded on by Ferdinand and up popped Cisse to stab home from close range to send the home crowd into ecstasy.
Crouch missed a chance to grab an equaliser in the four minutes of added time as QPR held on for a valuable win which was followed by a huge pitch invasion.
News of two late goals at Bolton lifted spirits further and the players came back on to the pitch after the final whistle to salute their jubilant and relieved support.