Lee Camp's injury-time penalty save prevented QPR pulling off an incredible comeback against Birmingham, who held on for a 4-3 win after being four up.
Che Adams scored a first-half hat-trick at Loftus Road, where the home side stormed back and would have snatched a point had former Rs keeper Camp not kept out Nahki Wells' spot-kick.
Adams has now scored in six consecutive Sky Bet Championship matches and his treble, plus Harlee Dean's header, blitzed Rangers before Matt Smith scored just before and after half-time.
Jordan Cousins' goal – his first for QPR – with 10 minutes remaining turned up the pressure on Birmingham.
And after Craig Gardner was adjudged to have fouled Luke Freeman, Wells had the chance to complete the comeback but was unable to beat Camp.
Adams' goals took his tally to the season to 19 and the striker closer to matching Trevor Francis' 31-year-old club record of scoring in seven successive league games.
He netted twice in the space of five minutes to put his team in control and then pounced again after ex-Brentford defender Dean had made it 3-0 on his return to west London.
Adams opened the scoring on 21 minutes. He turned away from defender Joel Lynch and fired past keeper Joe Lumley, who was back-pedalling having come off his line to meet Gary Gardner's long ball forward only to change his mind.
Adams doubled the visitors' lead by coolly rounding Lumley and slotting into an empty net after collecting ex-Brentford playmaker Jota's defence-splitting pass.
And the former Brentford contingent combined for the third goal, with Dean heading in Jota's 36th-minute corner.
Jota was also involved in the build-up to the fourth, scored six minutes later. After he exchanged passes with Jacques Maghoma and curled a shot against the post, the ball struck a confused Lumley and Adams followed up to finish from close range.
Smith gave Rangers a crumb of comfort by heading in Freeman's corner in first-half injury time.
He also buried Wells' low cross three minutes after the restart before fine saves by Camp kept the hosts at bay until Cousins made it 4-3.
Camp denied Smith a hat-trick by tipping over the target man's deflected strike and denied Freeman after Smith had headed down Jake Bidwell's left-wing cross.
Camp was at fault for Rangers' third goal, flapping at Freeman's cross before Cousins thumped home, but he redeemed himself in dramatic fashion.
His save ensured that Birmingham, who have lost just one of their last seven away league matches, held on for a potentially vital win in their pursuit of a play-off place.
QPR deserve credit for a spirited fightback and have an FA Cup fifth-round tie at home to Watford to look forward to, but this was their fourth defeat of a six-game winless run in the league.
ga('create', 'UA-72310761-1', 'auto', {'name': 'pacontentapi'});
ga('pacontentapi.set', 'referrer', location.origin);
ga('pacontentapi.set', 'dimension1', 'By Press Association Sport staff');
ga('pacontentapi.set', 'dimension2', 'b77bb0b8-46d8-47a0-a2c7-419d0082421a');
ga('pacontentapi.set', 'dimension3', 'paservice:sport,paservice:sport:club-news,paservice:sport:football,paservice:sport:match-reports');
ga('pacontentapi.set', 'dimension6', 'story');
ga('pacontentapi.set', 'dimension7', 'composite');
ga('pacontentapi.set', 'dimension8', null);
ga('pacontentapi.set', 'dimension9', 'sport:football');
ga('pacontentapi.send', 'pageview', { 'location': location.href, 'page': (location.pathname + location.search + location.hash), 'title': 'Camp rescues thrilling win for Birmingham after Adams treble'});