Josh Scowen scored a 90th-minute winner as Barnsley ended QPR’s winning start to the Championship season.
The hosts took the lead through Marley Watkins’ free header at the back post.
QPR turned the game around with two penalties, as Tjaronn Chery fired down the middle and Sebastian Polter placed his strike into the corner.
Conor Hourihane’s spectacular free-kick levelled and Scowen finished on the half-volley to snatch a dramatic win before Rangers had Grant Hall sent off.
The defender was shown a second yellow card within half an hour in injury time for pulling down Stefan Payne.
Barnsley move up to seventh in the table with their second win of their season, while QPR are fifth on goal difference.
The hosts were unchanged from their victory over Derby on Saturday and a good start saw them take the lead when Alfie Mawson headed the ball across the box for Watkins to nod in from three yards.
Scowen glanced a header wide but QPR grew in strength as the game went on and Chery’s free-kick came back off the crossbar.
Just 30 seconds into the second half, Chery made it 1-1 from the spot after Polter was brought down by Marc Roberts.
Polter then netted a penalty himself when James Bree clipped the heels of Yeni Ngbakoto.
But Barnsley won it with a dramatic turnaround as Hourihane’s free-kick flew into the top corner and the winner arrived when Scowen pounced after Payne’s nod down.
Barnsley head coach Paul Heckingbottom told BBC Radio Sheffield:
“I’m delighted with the result. Adam Davies didn’t have a shot to save, apart from the two penalties.
“We watched a lot of QPR in the first few games and they really dominated teams with the aggression, organisation and running power, but we more than matched them.
“We got what we deserved and the pleasing thing is we can get better.”
QPR manager Jimmy Floyd Hasselbaink:
“Barnsley were the better side in the first half, but we got ourselves together in the second half and played better and got the two goals from deserved penalties.
“But if the referee is going to give one of those soft free-kicks for their second goal, that he hasn’t been giving all game, I think that is painful.
“And then the third goal, what is the difference between the second goal? The player is in the air, trying to win the ball, he gets a nudge, what is the difference? I don’t understand it.
“Referees need to make decisions and it looked like the wild west out there. They could do what they wanted, there was no authority.”