Famara Diedhiou netted an injury time penalty to give Bristol City a 2-1 Championship win over QPR at Ashton Gate and extend their winning streak to nine games.
The visitors went in front just before the break when a header from Nahki Wells came back off a post and presented strike partner Matt Smith with a simple tap-in.
But substitute Niclas Eliasson levelled for City in the 73rd minute, accepting a Jamie Paterson pass and cutting in from the right to bury a left-footed shot from just inside the box.
Diedhiou settled the outcome at the start of five minutes of stoppage time. Having been fouled by Darnell Furlong, the big striker got up to net with a powerful spot-kick.
City are now unbeaten in 15 League and cup games. But the result was rough on Rangers and their manager Steve McClaren left the pitch remonstrating angrily with referee Tony Harrington.
His side had a couple of penalty shouts rejected an also contested the decision against Furlong, which led to the winner.
Rangers deserved their interval lead, having created the better chances. Smith was a constant threat in the air and McClaren's men were solid at the back and swift on the counter attack.
City put in the first effort of the game when Josh Brownhill fired narrowly wide from 25 yards, but the hosts suffered a blow in the 17th minute when Andreas Weimann was forced to hobble off. He was replaced by Eliasson.
Former City favourite Luke Freeman enjoyed an influential return to Ashton Gate and was only just off target with a 20-yard shot after an error by Lloyd Kelly.
Smith had a header saved by Frank Fielding from Freeman's 38th minute chip and the big target-man nodded over and straight at the City keeper with two other efforts.
Just before the opening goal, Brownhill went close again for the home side, but it was no great surprise when they fell behind after a strangely lacklustre first period.
City started the second half more brightly and should have equalised in the 56th minute when Eliasson's chip presented Diedhiou with a great chance. His close range header was too close to Joe Lumley, who made a smart reaction save.
There was a lot more urgency to City's play after the break and they exerted growing pressure. But Rangers were well served by centre-backs Darnell Furlong, Grant Hall and the outstanding Toni Leisner.
They won most of the aerial battles in the box as Eliasson, in particular, provided a series of testing crosses.
Diedhiou almost made it 3-1 at the death, but his shot was saved by Lumley.