Kris Boyd scored twice as Nottingham Forest strengthened their grip on a Championship play-off spot.
Boyd fired in when David James spilled Lewis McGugan's 30-yard free-kick in front of goal and then with a penalty after Louis Carey tripped McGugan.
Bristol City bounced back after half time, Marvin Elliott heading beyond Lee Camp before Jon Stead headed in Jordan Spence's centre to level.
But Luke Chambers earned Forest a vital three points with a looping header.
Sixth-placed Forest are two points ahead of Millwall and Burnley, with two games to play, while fifth-placed Reading are four points clear of the Reds.
The influential McGugan, who had a hand in all three goals, set up Boyd's opener after only four minutes - the striker, on loan from Middlesbrough, making no mistake in beating James from close range after the former England goalkeeper fumbled McGugan's free-kick.
Stead had two half-chances to equalise, first shooting just wide and then almost benefiting when Paul Konchesky's header did not quite reach Camp but the Forest keeper was alert and stifled the opportunity.
Jamal Campbell-Ryce also went close but dragged his shot past the post before, against the run of play, Forest extended their lead.
McGugan fell over Carey's dangling leg and Boyd smashed the resulting penalty into the roof of the net.
But Forest never looked entirely comfortable and a superb passing move involving four City players saw Campbell-Ryce get free down the left and cross for Elliott to sneak his far-post header beyond Camp and make it 2-1 four minutes into the second half.
Stead then headed City level on the hour mark, guiding Spence's cross back across Camp who got a hand to the ball but could not keep it out.
It looked like neither side would find a winner, until Chambers' looping header from McGugan's corner in the 72nd minute.
City thought they had salvaged a draw in injury time when Marlon Jackson scored but the substitute put the ball in the net with his hand and was booked by the referee, Roger East.