Matt Smith nodded QPR in front before their former winger Junior Hoilett equalised by blocking goalkeeper Alex Smithies' clearance.
Sol Bamba's header gave Cardiff the lead, fuelling a fiery atmosphere at Cardiff City Stadium.
The hosts had chances to score a third but held out comfortably for a fifth win from five league games.
Their victory, coupled with Ipswich's defeat at home to Fulham, means the Bluebirds are now three points clear at the Championship's summit.
There was an expectant crowd at Cardiff City Stadium, but the sense of optimism stemming from the hosts' perfect start to the season was punctured by Smith's opener, as he nodded in from close range after Cardiff goalkeeper Neil Etheridge failed to clear Luke Freeman's cross.
Etheridge will have been disappointed with his hesitant effort, though it paled into insignificance compared to his opposite number Smithies' blunder.
Under pressure from a poor back-pass by his captain Nedum Onuoha, the QPR goalkeeper's clearance ricocheted off Hoilett and straight into the net.
Those two goals were typical of a compelling encounter played at breakneck speed, as entertaining because of its errors and robust challenges as it was because of its goals and chances at both ends.
It was fitting too that this battle should include a headed goal from a corner for Bamba, whose aerial duels with his adversary Smith were so brutal that they could have registered on the Richter scale.
Cardiff maintained the frenetic tempo in the second half and, buoyed by a vociferous home crowd, they twice went close to a third goal as Hoilett had one effort disallowed for a push before Nathaniel Mendez-Laing struck the crossbar.
Kenneth Zohore was then denied by a brilliant close-range save from Smithies as Cardiff continued to press but, with QPR offering little in attack, it was an ultimately simple fifth consecutive league win for Neil Warnock's in-form side.
Cardiff City manager Neil Warnock told BBC Radio Wales:
"Obviously I'm pleased. We made hard work of it at times but I was delighted with the way we played.
"We showed a lot of character, played some good stuff on the front foot, created some good chances. I thought [QPR goalkeeper Alex] Smithies was brilliant.
"It's a happy place and I'm really glad we've got two weeks off now [for the international break] without a press conference."
Queens Park Rangers manager Ian Holloway said:
"We were doing fine when we got in front, we looked pretty comfortable and then it changed when we conceded the first goal, the manner of it, the timing of it. We could have dealt with it better.
"Unfortunately they forced us into a mistake and it knocked the stuffing out of us, got the crowd up. They then go and score from a set-play.
"On the balance of play, that's as good a Cardiff team as I've ever seen. It's going for them at the minute - they're making it go for them. They looked a real solid unit.
"The Bluebirds will be buzzing tonight but we weren't that far off them."
Match ends, Cardiff City 2, Queens Park Rangers 1.
Second Half ends, Cardiff City 2, Queens Park Rangers 1.
Corner,  Cardiff City. Conceded by Alex Smithies.
Attempt saved. Nathaniel Mendez-Laing (Cardiff City) right footed shot from the left side of the box is saved in the bottom left corner.
Corner,  Queens Park Rangers. Conceded by Neil Etheridge.
Attempt missed. Matt Smith (Queens Park Rangers) left footed shot from the centre of the box is close, but misses to the left. Assisted by Yeni N'Gbakoto.
Attempt missed. Luke Freeman (Queens Park Rangers) left footed shot from the centre of the box is close, but misses to the left.
Substitution, Cardiff City. Bruno Ecuele Manga replaces David Junior Hoilett.
Offside, Cardiff City. Joe Ralls tries a through ball, but Nathaniel Mendez-Laing is caught offside.
Attempt missed. Josh Scowen (Queens Park Rangers) right footed shot from outside the box is high and wide to the right. Assisted by Jake Bidwell with a headed pass.
Joe Bennett (Cardiff City) wins a free kick in the defensive half.
Foul by Matt Smith (Queens Park Rangers).
Attempt missed. David Junior Hoilett (Cardiff City) left footed shot from the left side of the box misses to the left following a set piece situation.
Attempt blocked. Sean Morrison (Cardiff City) header from the centre of the box is blocked. Assisted by Joe Ralls with a cross.
Kenneth Zohore (Cardiff City) wins a free kick on the left wing.
Foul by Massimo Luongo (Queens Park Rangers).
Kenneth Zohore (Cardiff City) wins a free kick on the left wing.
Foul by Darnell Furlong (Queens Park Rangers).
David Junior Hoilett (Cardiff City) wins a free kick in the defensive half.
Foul by Jake Bidwell (Queens Park Rangers).
Substitution, Cardiff City. Danny Ward replaces Loïc Damour.
Foul by Loïc Damour (Cardiff City).
Massimo Luongo (Queens Park Rangers) wins a free kick in the defensive half.
Delay over. They are ready to continue.
Delay in match Jake Bidwell (Queens Park Rangers) because of an injury.
Attempt missed. Kenneth Zohore (Cardiff City) right footed shot from outside the box is high and wide to the right. Assisted by Loïc Damour.
Attempt saved. Kenneth Zohore (Cardiff City) left footed shot from the centre of the box is saved in the bottom left corner. Assisted by Nathaniel Mendez-Laing.
Attempt missed. David Junior Hoilett (Cardiff City) right footed shot from outside the box is high and wide to the left. Assisted by Kenneth Zohore.
Delay over. They are ready to continue.
Delay in match Lee Peltier (Cardiff City) because of an injury.
Substitution, Queens Park Rangers. Pawel Wszolek replaces Steven Caulker.
Substitution, Queens Park Rangers. Yeni N'Gbakoto replaces Conor Washington.
Delay over. They are ready to continue.
Delay in match Kenneth Zohore (Cardiff City) because of an injury.
Delay in match Darnell Furlong (Queens Park Rangers) because of an injury.
Attempt saved. Joe Ralls (Cardiff City) left footed shot from the left side of the box is saved in the bottom left corner. Assisted by Kenneth Zohore with a headed pass.
Attempt saved. Sean Morrison (Cardiff City) header from the centre of the box is saved in the centre of the goal. Assisted by Joe Ralls.
Loïc Damour (Cardiff City) wins a free kick on the left wing.
Foul by Idrissa Sylla (Queens Park Rangers).
Corner,  Cardiff City. Conceded by Steven Caulker.
Cardiff City beat Queens Park Rangers in a breathless encounter to stay top of the Championship table.