Jamie Mackie scored a stunning equaliser after Jordan Rhodes had put Boro ahead, but the visitors took control in the second half.
Gaston Ramirez headed the visitors back in front from the resulting corner after goalkeeper Alex Smithies had saved Grant Leadbitter’s penalty six minutes into the second half.
Ben Gibson also nodded in from a corner five minutes later – the centre-back’s first league goal of the season – before Tjaronn Chery scored for Rangers late on.
Boro’s victory came after three consecutive away defeats and lifts them above Brighton, who face leaders Burnley today.
They went ahead after 17 minutes when Rhodes capitalised on an error by Grant Hall to score just his second goal since his move from Blackburn two months ago.
Mackie hauled Rangers level just after the half-hour mark with his first goal since returning to the club last summer.
Within 11 minutes of the restart Boro were 3-1 ahead.
Smithies dived low to his right to tip Leadbitter’s spot-kick behind after Faurlin had fouled Albert Adomah. But Leadbitter responded with a corner towards the near post that was headed in by Ramirez. Gibson drifted away from Nedum Onuoha at a corner to make it 3-1.
Dutch midfielder Chery scored in his fifth consecutive home match, firing into the corner from 25 yards with four minutes remaining.
QPR: Smithies, Onuoha, Hall, Angella, Perch, Mackie (El Khayati 69), Henry, Faurlin (Washington 79), Phillips (Hoilett 62), Chery, Polter. Unused substitutes: Luongo, Ingram, Petrasso, Robinson.
Middlesbrough: Konstantopoulos, Nsue, Kalas, Gibson, Friend, Clayton, Leadbitter, Adomah, Ramirez (Forshaw 67), Downing (Ayala 84), Rhodes (Nugent 78). Unused substitutes: De Laet, De Pena, De Sart, Agazzi.
Referee: Simon Hooper (Wiltshire).