Jon Stead's late goal saw off Leicester City and earned Bristol City a first win in eight games.
Lloyd Dyer fired the Foxes into the lead but Kalifa Cisse levelled on the stroke of half-time with a neat finish.
The Robins went ahead when Brett Pitman stroked home Stephen Pearson's pass, only for Neil Danns to scramble home an equaliser Tom Kennedy's cross.
Minutes later, Stead reacted quickest after Pitman hit the post to give the home side three points.
Victory lifted Derek McInnes's side five points clear of the Championship relegation zone.
Dyer opened the scoring four minutes before half-time, lashing into the top corner after the Bristol City defenders failed to clear their lines.
Bristol City responded through Cisse, who coolly slotted beneath goalkeeper Kasper Schmeichel, before Pitman struck nine minutes into the second half.
They were pegged back when goalkeeper David James was unable to cut out Kennedy's cross and Danns was on hand from close range.
But there was one more twist in the tale when striker Pitman, finding space in the penalty area, struck the woodwork and Stead pounced to bag his second goal of the season.
Bristol City manager Derek McInnes:
"I don't think anybody gave us a chance apart from the boys in our dressing room. We believed we would win the game.
"I felt we kept them at arm's length, that's why I was so disappointed to the lose the first goal.
"Thankfully there was enough spirit and energy amongst them to get back into the game.
"To do it the way we did it, against a team who don't concede many goals, and score three goals, was testament to the players."
Leicester City manager Nigel Pearson:
"We conceded some very poor goals and subsequently put the game at risk.
"Two goals away from home should be enough to win a game but the manner in which we conceded goals tonight is not pleasing.
"We've made mistakes at the back but we've not defended well enough as a team.
"It is frustrating because we've worked exceptionally hard in the last few weeks to try and get in contact with the places above us and you have a night like tonight, where all that hard work is almost undone because of the manner of the defeat.
"If you lose a tight game where a bit of brilliance wins it you've got no complaints but I'm disappointed tonight with the manner of our defeat."
- 01 James
- 03 McAllister Booked
- 04 Fontaine
- 06 Carey
- 28 McManus
- 21 Cisse
- 26 Foster
- 31 Bryan (Adomah - 69' )
- 37 Pearson
- 09 Stead Booked (Wood - 81' )
- 34 Pitman (Kilkenny - 84' )
- 22 Gerken
- 08 Kilkenny
- 17 Bolasie
- 27 Adomah
- 39 Wood
- 01 Schmeichel
- 02 Peltier
- 12 St Ledger
- 26 Morgan
- 30 Kennedy
- 11 Dyer
- 19 Wellens Booked
- 22 Marshall (Drinkwater - 60' )
- 23 Danns (Gallagher - 87' )
- 20 Beckford (Schlupp - 60' )
- 35 Nugent
- 06 Bamba
- 16 Drinkwater
- 27 Schlupp
- 07 Gallagher
- 09 Howard
Live Text Commentary
Full Time The referee ends the match.90:00 +3:40
Effort on goal by David Nugent from just inside the area clears the bar.86:22 Substitution
Substitution Neil Danns leaves the field to be replaced by Paul Gallagher.85:32
Lloyd Dyer challenges Richard Foster unfairly and gives away a free kick. Neil Kilkenny delivers the ball from the free kick right-footed from right wing, clearance by Daniel Drinkwater.83:58
Unfair challenge on Daniel Drinkwater by Kalifa Cisse results in a free kick. Daniel Drinkwater has an effort direct from the free kick, save by David James.83:11 Substitution
Substitution Brett Pitman goes off and Neil Kilkenny comes on.81:28
Free kick crossed left-footed by Tom Kennedy, Chris Wood manages to make a clearance.81:28 Booking
Booking Jamie McAllister is shown a yellow card for unsporting behaviour.81:23
David Nugent fouled by Jamie McAllister, the ref awards a free kick.80:25 Substitution
Substitution Chris Wood joins the action as a substitute, replacing Jon Stead.78:59
The assist for the goal came from Brett Pitman.78:59 Goal scored
Goal! - Jon Stead - Bristol C 3 - 2 Leicester A goal is scored by Jon Stead from close range to the bottom left corner of the goal. Bristol City 3-2 Leicester.76:13
Tom Kennedy provided the assist for the goal.76:13 Goal scored
Goal! - Neil Danns - Bristol C 2 - 2 Leicester Neil Danns gets on the score sheet with a goal from inside the six-yard box to the bottom right corner of the goal. Bristol City 2-2 Leicester.72:20
Corner taken left-footed by Tom Kennedy from the right by-line, Kalifa Cisse makes a clearance.68:01 Substitution
Substitution Albert Adomah on for Joe Bryan.67:47
Shot from deep inside the area by David Nugent goes over the bar.67:00
The offside flag is raised against Jon Stead. Sean St. Ledger takes the free kick.65:31
Tom Kennedy takes a inswinging corner to the near post, Jon Stead makes a clearance.64:24
Lloyd Dyer delivers the ball, Neil Danns produces a right-footed shot from close range which goes wide of the right-hand post.
Shot on goal by Brett Pitman from just inside the area goes over the target.62:00
David Nugent takes a shot. Save by David James.59:24 Substitution
Substitution Jeffery Schlupp comes on in place of Jermaine Beckford.59:24 Substitution
Substitution Daniel Drinkwater replaces Ben Marshall.58:22
Shot by Brett Pitman from outside the box goes over the target.56:47
The assistant referee flags for offside against Wes Morgan. David James takes the free kick.56:22
Wes Morgan takes a shot. Save by David James.55:28
Stephen Pearson gives away a free kick for an unfair challenge on Jermaine Beckford. Tom Kennedy crosses the ball from the free kick left-footed from right channel, Louis Carey makes a clearance.53:39
Assist on the goal came from Stephen Pearson.53:39 Goal scored
Goal! - Brett Pitman - Bristol C 2 - 1 Leicester Brett Pitman gets on the score sheet with a goal from close range to the top left corner of the goal. Bristol City 2-1 Leicester.52:59
Unfair challenge on Richie Wellens by Brett Pitman results in a free kick. Richie Wellens takes the indirect free kick.50:45
The ball is delivered by Ben Marshall.49:07
Free kick awarded for a foul by Jamie McAllister on Ben Marshall. Indirect free kick taken by Richie Wellens.47:29
Inswinging corner taken by Brett Pitman, save by Kasper Schmeichel.47:22
Stephen Pearson produces a cross, blocked by Lee Peltier.45:59
Jon Stead takes a shot from inside the box clearing the bar.45:01
The referee gets the second half underway.45:00 +2:29 Half time
Half Time The players leave the pitch at half time.45:00 +0:53
Assist by Jon Stead.45:00 +0:53 Goal scored
Goal! - Kalifa Cisse - Bristol C 1 - 1 Leicester Goal scored by Kalifa Cisse from inside the six-yard box to the bottom right corner of the goal. Bristol City 1-1 Leicester.44:46
Close range effort by Kalifa Cisse misses to the left of the target.43:14
Free kick awarded for an unfair challenge on Richard Foster by Tom Kennedy. The free kick is delivered right-footed by Jamie McAllister from right wing, Sean St. Ledger makes a clearance.40:39 Goal scored
Goal! - Lloyd Dyer - Bristol C 0 - 1 Leicester Lloyd Dyer finds the back of the net with a goal from close range to the top right corner of the goal. Bristol City 0-1 Leicester.37:47
Inswinging corner taken by Tom Kennedy, clearance made by Stephen McManus.37:11
Corner taken left-footed by Tom Kennedy from the left by-line, Stephen Pearson manages to make a clearance.36:31
The referee blows for offside against David Nugent. Jamie McAllister restarts play with the free kick.33:00
Inswinging corner taken right-footed by Brett Pitman played to the near post, Neil Danns makes a clearance.32:46
Jon Stead takes a shot. Blocked by Lloyd Dyer.31:32
Kalifa Cisse concedes a free kick for a foul on Neil Danns. Sean St. Ledger takes the free kick.30:35
Lloyd Dyer is ruled offside. David James takes the indirect free kick.29:20
The ball is swung over by Brett Pitman.28:39
Ben Marshall takes a inswinging corner to the near post, Jon Stead manages to make a clearance.27:52
Inswinging corner taken from the right by-line by Tom Kennedy, Stephen McManus manages to make a clearance.27:16
Ben Marshall produces a cross.26:23
Stephen Pearson takes a shot. Blocked by Wes Morgan.25:53
Free kick awarded for a foul by Richie Wellens on Brett Pitman. Louis Carey restarts play with the free kick.24:03
Free kick awarded for a foul by Jon Stead on Wes Morgan. Indirect free kick taken by Kasper Schmeichel.23:13
Centre by Ben Marshall.22:16
Jamie McAllister crosses the ball, Brett Pitman has a header from close in and clears the crossbar.21:44
Jamie McAllister takes a inswinging corner from the right by-line played to the near post, clearance made by Neil Danns.21:35
The ball is swung over by Brett Pitman, clearance made by Sean St. Ledger.21:02
Jon Stead takes a shot. Save by Kasper Schmeichel.20:07
The ball is delivered by Ben Marshall, clearance by Liam Fontaine.14:38
Brett Pitman fouled by Richie Wellens, the ref awards a free kick. Stephen Pearson takes the free kick.12:01
Brett Pitman takes a shot. Save by Kasper Schmeichel.10:56
Ben Marshall crosses the ball from the free kick right-footed from left wing, clearance by Jamie McAllister.10:56 Booking
Booking The referee cautions Jon Stead for unsporting behaviour.10:51
Free kick awarded for an unfair challenge on Lloyd Dyer by Jon Stead.9:45
Free kick awarded for a foul by David Nugent on Stephen McManus. Free kick taken by David James.8:14 Booking
Booking Richie Wellens is booked.7:23
Joe Bryan fouled by Richie Wellens, the ref awards a free kick. Free kick taken by Kalifa Cisse.6:46
Foul by Richard Foster on Jermaine Beckford, free kick awarded. Indirect free kick taken by Tom Kennedy.2:33
Shot by Brett Pitman from outside the box goes high over the crossbar.1:45
Sean St. Ledger challenges Jon Stead unfairly and gives away a free kick. Free kick crossed left-footed by Jamie McAllister, clearance made by Neil Danns.0:00
The referee starts the match.
Live data and text provided by our data suppliers