Andy Gray kept Sheffield United's play-off hopes alive with a coolly taken last-minute penalty after on-loan striker Danny Webber had struck twice.
United now face an important home game on Tuesday against struggling Nottingham Forest while QPR's faint hopes of a top-six finish have disappeared.
Former United midfielder Georges Santos almost snatched the opener with a slick move in the 12th minute which sliced through the Sheffield back four. Santos, playing up front in place of the injured Paul Furlong, linked cleverly with Lee Cook only for his low shot to be blocked by Rob Kozluk.
Argentinian Gino Padula kept out Webber as the United striker steamed towards the edge of the area before Rangers swept ahead in the 26th minute.
Santos was again involved, this time feeding midfielder Martin Rowlands whose right-foot strike took a slight deflection off centre back Leigh Bromby and flew into the bottom right hand corner.
United were almost level six minutes later, when leading scorer Gray stretched to snap in a header from Jon Harley's cross but Simon Royce pushed the ball round the post.
Rangers soaked up a spell of pressure and caught United on the break in the 38th minute when the lively Cook picked out Kevin Gallen, who powered his shot high and wide from 16 yards.
Alan Quinn saw his stinging shot on the turn fly inches wide of the target before United moved level two minutes before the interval. Centre-back Dan Shittu was caught out of position on the halfway line and Webber swept into the area to beat Royce from 10 yards.
Bromby saw a header blocked and Webber shot wide before he put United ahead on 53 minutes. Harley's blistering shot from 25 yards was tipped onto the bar by Royce and Webber headed the rebound into the unguarded net with the keeper stranded.
United skipper Chris Morgan steered a Gallen shot past his own keeper in the 66th minute before Santos brought down Bromby in the last minute for Gray to strike the winner.
There was further misery for Rangers seconds from time when defender Andrew Davies was red carded for his second bookable offence.