The Bulls had looked good value for a replay after holding their higher-graded opponents throughout the match but the late goal put their FA Cup hopes in tatters.
John-Joe O’Toole struck four minutes into injury time to snatch Colchester a last-gasp win over Hereford and earn them a place in the FA Cup third round.
The striker hammered the ball past keeper Adam Bartlett from 12 yards from Anthony Wordsworth’s lay-off.
It was heartbreaking for Hereford, who struck the bar through Gavin McCallum, while Darren Jones forced a fine save.
But the U’s, who saw a Kayode Odejayi effort cleared off the line, settled the tie late on to stay in the Cup.