The Black Cats went two goals up early in the second half when Nicklas Bendtner and Stephane Sessegnon netted either side of the break before the Râ€™s struck back twice via Heidar Helguson and Jamie Mackie in quick succession.
But just as it was headed for a draw, Wes Brown bobbed up to be the unlikely match-winner for Sunderland with a 89th minute header which was his first goal for the club.
Bendtner opened up the scoring in the 19th minute with his third of the season courtesy of a front post header from Kieran Richardsonâ€™s corner before things got even better for the visitors when Sessegnon got on the end of the Daneâ€™s midfield flick-on to advance into the area, round Râ€™s keeper Paddy Kenny, and slot home to double the advantage.
QPR hit back in the 63rd minute when Helguson finished a great move which involved Adama Traore and ended in Alejandro Faurlin supplying a low cross for the Icelandic veteran who bundled home for his seventh of the campaign.
Neil Warnockâ€™s men were then on level terms four minutes later with Faurlin chipping into the area for Helguson to head into the path of diving Mackie who nodded past Keiren Westwood after just coming on as a substitute.
But with a share of the points looking likely, Brown got to Richardsonâ€™s corner to glance in a front post header which was cannoned onto the crossbar from Faurlin on the line and in for the winner to send Sunderland to 15th with their second win in three under Oâ€™Neill as QPRâ€™s poor home run continues as they drop to 16th as their winless streak stretches to five.
TRIBAL ASKS: Is Martin Oâ€™Neill the man to get Sunderlandâ€™s season back on track? On the other side of the coin, are QPR good enough to avoid relegation?
Loftus Road, London â€“ 16,167