Colchester striker Wayne Andrews struck a late winner to put a dent in Chesterfield's survival bid.
The former Oldham man nodded into an empty net nine minutes from time after Carl Muggleton could only palm Craig Fagan's close-range effort into the air.
Greg Halford had earlier put the U's ahead when he fired an unstoppable 30-yard free-kick past Muggleton and into the top corner on the half-hour.
Halford went close to doubling his side's advantage moments later with another long-range effort before Glynn Hurst hauled Roy McFarland's men level five minutes after the break.
The Spireites top scorer headed home unmarked at the far post from Chris Brandon's looping cross for his 11th goal of the season.
Hurst was then denied first by U's keeper Simon Brown and then the inside of the post as Chesterfield looked to put some space between themselves and the drop zone.
But Andrews came off the bench with 24 minutes left and earned his side's first away win since October.
After the game an upset Chesterfield boss Roy McFarland said: "Our first-half play was totally inept.
"We were better after the break and created chances but just could not put them away.
"One of the things you have to do when attacking is keep the back door shut but we failed to do that.
"Every game is important and it's disappointing to lose two on the trot at home after doing so well here recently." But delighted Colchester boss Phil Parkinson said: "This was a massive result for us. A lot of teams might have folded after their goal but we rolled up our sleeves, showed some character, and our spirit carried us through in the end."