Marcus Tudgay grabbed a 91st-minute winner to pull Nottingham Forest away from the wrong end of the table in a topsy-turvy match against Ipswich.
Danny Collins headed home Aaron Cresswell's cross to hand Ipswich an early lead, but Robbie Findley tucked home Forest's first equaliser.
Town's lead was restored when Collins met Jimmy Bullard's corner to nod in.
But Joel Lynch converted Andy Reid's cross to level it up on 83 minutes before Tudgay headed his late winner.
It was tough luck on an Ipswich side that looked primed to end a run of three straight defeats with at least a draw - but Forest boss Steve Cotterill will be delighted to have overseen a fourth league win since succeeding Steve McClaren as manager.
The hosts edged a keenly contested first half but were only able to go in at the break level.
Collins, on loan from Stoke, headed Ipswich into an early lead against the run of play, though Findley cancelled that out when he fired in his fifth of the season from Lewis McGugan's free-kick.
And when Collins, who before kick-off had not scored a league goal in two years, rose to glance home Bullard's corner it looked like Ipswich were on course for victory.
But a frantic final 10 minutes put paid to the visitors' hopes.
Seven minutes from time, Reid bustled up the left wing to supply Lynch with a tidy cross, the ex-Brighton man nodding home a valuable first goal for the club.
And Tudgay broke Town's hearts in the first minute of stoppage time as Greg Cunningham lofted in an accurate pass which the former Sheffield Wednesday frontman nodded home.