A pair of goalkeeping errors from Iain Turner ensured Nottingham Forest twice had to fight back from behind, but they still snatched a vital victory in their fight against relegation.
A last-minute strike from on-loan Dexter Blackstock secured a dramatic 3-2 success for the home side and virtually brought an end to Bristol City's hopes of making the play-offs.
City had twice taken the lead firstly through Ivan Sproule and then - after Robert Earnshaw had equalised - when Dele Adebola pounced for a simple header.
But substitute Joe Garner bundled Forest level after Jamie McAllister had been sent off for his second booking of the game.
And Blackstock struck in the final minute to complete the fightback and secure a massive win for Billy Davies' side.
Forest almost made a dramatically quick start to the game as a lay-off from Earnshaw gave Chris Cohen the chance to bend a low 20-yard shot goalwards, with Adriano Basso reacting well to pounce on the ball.
The City keeper should have been helpless when a Cohen free-kick then picked out Blackstock for a free header from close range, but the on-loan striker headed agonisingly wide.
Michael McIndoe's athleticism almost engineered an opening for Bristol as he connected with a spectacular overhead kick that bounced narrowly wide.
A mistake from Wes Morgan allowed Nicky Maynard to burst through the centre, with Kelvin Wilson sliding in bravely to block the striker's shot.
Another error at the back was to cost Forest dear however as keeper Turner failed to collect a whipped in cross from Lee Johnson, allowing the ball to slip from his grasp at the far post, where Sproule shook off the attentions of Joel Lynch to bundle home.
An Earnshaw overhead kick and a Cohen lob saw Forest come close to an equaliser but Bristol City were also a threat, with Jamie McCombe seeing a towering header superbly clawed away by Turner.
A short spell of pressure was eventually to tell for the home side, as the powerful figure of Blackstock, who had been dominant in the air, brought the ball down before cleverly feeding Earnshaw in the box.
His strike partner then cleverly sidestepped McCombe in the box, before prodding a low shot into the bottom corner from eight yards.
Forest could have been ahead within five minutes as on-loan full-back Chris Gunter curled a placed shot narrowly around the foot of the post.
The second half began with Joel Lynch sliding the ball wide of the post after a Cohen free-kick had caused panic in the six-yard box and Paul Anderson lifting a fearsome drive narrowly over.
But it took a dramatic goal-line clearance from Wilson to keep the scores level, after Sproule had beaten both defender Lynch and keeper Turner in a race for a through-ball on the edge of the box.
Forest substitute Garath McCleary's pace was causing problems for City however, with the young winger hitting the sidenetting with a low shot.
But it was another painful moment from Turner that was to swing the game in City's favour, as the keeper failed to collect a high ball just inside the penalty area, with Adebola beating him to it and lifting a simple headed finish into an empty net.
The drama was far from over however as, with seven minutes remaining, Bristol's McAllister was sent off after picking up his second booking of the game for hauling down Gunter.
From the resulting free-kick, substitute Garner bundled home an equaliser at the near post from another incisive Cohen delivery.
And, in the 90th minute, Blackstock drove an emphatic finish into the back of the net to secure Forest victory, pouncing on a knock-down from Lynch.