Colchester produced a fine display as Notts County suffered just their second defeat in 11 games.
The U's struck first through Anthony Wordsworth's free-kick before Sam Sodje headed home to equalise for County.
Michail Antonio prodded in to put the U's back in front, before Ian Henderson lashed in from 20 yards out.
Kayode Odejayi then slotted home for the hosts before County replied late on after Matt Heath deflected Jeff Hughes' shot into the net.
VIEWS FROM THE DRESSING ROOM
Colchester manager John Ward told BBC Essex:
"It was a good game for us because we had to be patient in the first period. We could have scored, their goalkeeper's made some fantastic saves to keep them in the game.
"Then it's a question of being strong and brave and keeping your decision-making correct and we've done that as well.
"I'm delighted with the way that my team has responded to the whole game. We changed the format slightly, and then we've had to change it again with Steven Gillespie coming off."
Notts County manager Martin Allen told BBC Radio Nottingham:
"I thought we were very comfortable in the first half - by keeping possession without creating too many chances. But we were very comfortable. I don't think they had any efforts on our goal and for an away team that's pretty good going.
"But then the second half, when we got the equaliser, we did have a crazy 10 minutes. We gave the ball away - giving away fouls, poor decision-making.
"But that's OK, we're on a long journey. Through that long journey there's going to be a few dodgy days, where you have a few flat tyres, a few hiccups along the way - and today was one of them."