Tommy Conway scored in the sixth minute of injury time to earn Bristol City a last-gasp 2-1 win at Rotherham in the Sky Bet Championship.
Conway had opened the scoring in the 81st minute but the Millers quickly equalised through Tyler Blackett and it looked like it was heading for a draw.
But there was late drama at the AESSEAL New York Stadium as Conway struck at the death, flicking home Andy King's cross.
It earned a third away win of the season and moves the Robins back into the top half, continuing their solid start.
Defeat was cruel on the Millers but typifies their troubled opening to the campaign and they are locked in the bottom three with a long winter looming in their battle to stay out of relegation danger.
Boss Matt Taylor celebrated one year in charge at the club on Tuesday, but he might now face questions about his future.
Any chance of retaining their Championship status appears to lie with their home form, which has been competitive.
They could have taken a 23rd-minute lead when Cohen Bramall's cross was headed back across goal by Jordan Hugill but Andre Green was not forceful enough to turn home from close range.
Bramall was Rotherham's biggest threat and he fizzed a dangerous ball into the near post which just evaded Hugill.
Another cross was headed over by Fred Onyedinma as the Millers continued on the front foot.
The Robins were able to get a foothold in the game, but that turned it into a dull, scrappy affair where neither goalkeeper was forced into a save.
That pattern continued into the second half, with neither side able to create any sort of domination.
The visitors did at least manage to improve going forward after the break and got into some good positions, but that did not translate into chances.
The closest they came was when Harry Cornick headed over from Sam Bell's cross, while the first shot on target did not come until the 67th minute when Joe Williams shot straight at Viktor Johansson.
It was heading for stalemate until nine minutes from the end of normal time when Conway broke down the left, cut inside and curled a beauty into the far corner.
The Millers hit back with their first shot on target, Blackett converting from Arvin Appiah's cross after the hosts had recycled a corner.
They fancied a winner, but instead it came at the other end as Conway had the final say, flicking home Andy King's cross.