Barnsley are off the bottom of Sky Bet League One after they hung on to win at fellow strugglers Colchester.
The rejuvenated Reds had been cruising along with a seemingly unassailable 3-0 lead, but two quick goals from the U’s made for a frantic finish.
However, Lee Johnson’s men hung on and registered a potentially precious victory.
The Reds were dominant in the first half at the Weston Homes Community Stadium, and deservedly led by two goals at the interval.
The visitors had already gone close before they broke the deadlock in the 18th minute.
Early on skipper Alfie Mawson saw his thumping header superbly saved by Jamie Jones, with the rebound falling to Adam Hammill, who curled a shot inches past the post.
Conor Hourihane opened the scoring, slotting home his seventh goal of the season from close range after Sam Winnall had initially been forced wide by ‘keeper Jones.
It was five minutes before the break when the lead was doubled.
This time Winnall rolled a perfect pass to Hammill, who crashed home clinically to register his third goal since returning to the Reds.
The U’s started the second half purposefully, and in the 47th minute they were denied by the woodwork as Tom Eastman nodded against the crossbar.
Richard Brindley also fired wide as the hosts sought a way back into contention.
The Reds weathered the mini-storm before forging their way further clear bang on the hour mark.
Ivan Toney made it 3-0, heading home his second goal in as many games as he met a smart Marley Watkins cross.
The U’s pulled one back in the 67th minute, with George Moncur slotting past Adam Davies after latching on to Chris Porter’s through-ball.
Porter then smashed home to make it 3-2, and with still 20 minutes left, the U’s were right back in contention.
Marvin Sordell and Porter went close towards the end, but the gutsy Reds hung on for the three points.
Colchester (4-2-3-1): Jones; Brindley, Eastman, Elokobi, Briggs; Gilbey, Edwards; Massey, Moncur, Harriott; Sordell.Subs: Parish, Vincent-Young, Kent, Szmodics, Lapslie, Bonne, Porter.
Barnsley (4-4-1-1): Davies; Wabara, Nyatanga, Mawson, White; Watkins, Pearson, Hourihane, Hammill; Winnall; Toney. Subs: Townsend, Roberts, Williams, Isgrove, Bree, Jackson, M Smith.
Referee: Stephen Martin (Staffordshire).