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.
Hereford defender Ryan Valentine told BBC Hereford and Worcester:
"When the draw came out, even though it was a team that is doing well in League One, we fancied our chances.
"Over the 90 minutes we have performed solidly more than spectacularly.
"But I think the least we deserved was a 0-0 draw and the chance to go down to their place and to go into the third round."
Colchester United manager, Aidy Boothroyd told BBC Essex:
"I'm delighted about it, there had been a few noises in the local press that they (Hereford) fancied their chances. They've got a good home record and it is these games that we must win if we're to win a league.
"Without being disrespectful, we have to put these lesser teams to the sword."
90:00+5:02 The referee blows for the end of the match.
90:00+3:14 Booking John-Joe O'Toole is cautioned.
90:00+3:09 Assist by Anthony Wordsworth.
90:00+3:09 GOAL - John-Joe O'Toole:Hereford 0 - 1 Colchester A goal is scored by John-Joe O'Toole from deep inside the penalty area to the bottom left corner of the goal. Hereford 0-1
90:00+3:09 The ball is swung over by Anthony Wordsworth,
89:15 Shot from 35 yards by Jordon Mutch went wide right of the net.
88:33 Kevin Lisbie concedes a free kick for a foul on Darren Jones. Adam Bartlett takes the direct free kick.
86:51 Substitution Marc Pugh replaces Craig King.
86:22 Philip Ifil takes a shot. Mathieu Manset gets a block in.
84:31 Sam Gwynne produces a left-footed shot from the edge of the box and misses to the right of the target.
84:11 Jordon Mutch takes a shot. Blocked by Magnus Okuonghae.
82:09 The ball is delivered by Philip Ifil, Daniel Blanchett makes a clearance.
80:57 The ball is crossed by Clive Platt.
79:53 A cross is delivered by Marc Tierney, save made by Adam Bartlett.
79:15 Mathieu Manset is ruled offside. Ben Williams restarts play with the free kick.
77:58 Free kick awarded for an unfair challenge on John White by Craig King. Ben Williams takes the free kick.
77:47 Inswinging corner taken from the left by-line by Philip Ifil.
77:38 Marc Tierney crosses the ball, Gavin McCallum gets a block in.
76:53 Inswinging corner taken by Philip Ifil, Sam Gwynne makes a clearance.
76:48 Philip Ifil sends in a cross.
76:18 Marc Tierney produces a cross, Ryan Valentine makes a clearance.
76:07+4:58 Short corner worked by Philip Ifil.
75:20 Mathieu Manset concedes a free kick for a foul on Magnus Okuonghae. Philip Ifil takes the direct free kick.
74:54 Jordon Mutch is adjudged to have handled the ball. Direct free kick taken by Paul Reid.
73:52 Substitution Anthony Wordsworth joins the action as a substitute, replacing Steven Gillespie.
70:14 The ball is crossed by Philip Ifil, blocked by Ryan Valentine.
69:40 Unfair challenge on Philip Ifil by Ryan Valentine results in a free kick. Direct free kick taken by John White.
68:05 Substitution Philip Ifil replaces Kayode Odejayi.
67:27 Gavin McCallum takes a shot. Save by Ben Williams.
66:33 Craig King concedes a free kick for a foul on John-Joe O'Toole. Ben Williams takes the free kick.
65:56 Inswinging corner taken right-footed by Jordon Mutch from the left by-line, clearance made by Clive Platt.
62:45 Gavin McCallum takes a shot. Daniel Blanchett takes a inswinging corner to the near post, Ben Williams makes a save. Clearance
by Marc Tierney.
60:37 Substitution Leon Constantine leaves the field to be replaced by Mathieu Manset.
Correction - 59:46 Booking The referee cautions Kemal Izzet for unsporting behaviour.
59:46 Booking The referee shows Kemal Izzet a yellow card for unsporting behaviour.
Correction - 59:23 Kemal Izzet gives away a free kick for an unfair challenge on Craig King. Free kick taken by Jordon Mutch.
59:23 Kemal Izzet gives away a free kick for an unfair challenge on Craig King. Jordon Mutch takes the free kick.
58:24 Kemal Izzet takes the outswinging corner, clearance by Craig King.
57:45 Outswinging corner taken by Kemal Izzet from the right by-line, Craig King makes a clearance.
56:30 Jordon Mutch concedes a free kick for a foul on John-Joe O'Toole. Kemal Izzet takes the free kick.
55:50 Ryan Valentine produces a cross.
54:31 The referee blows for offside against Gavin McCallum. Ben Williams takes the direct free kick.
52:29 The ball is sent over by Steven Gillespie, save made by Adam Bartlett. Ryan Valentine crosses the ball in from the free kick,
save by Ben Williams.
52:07 Foul by Jordon Mutch on Kemal Izzet, free kick awarded. Direct free kick taken by Ben Williams.
51:28 Kevin Lisbie is ruled offside. Adam Bartlett takes the free kick.
50:14 The ball is crossed by Craig King.
45:04 Substitution Sam Gwynne joins the action as a substitute, replacing Kenny Lunt.
45:01 The referee gets the second half started.
45:01 Substitution Simon Hackney goes off and Clive Platt comes on.
45:00+1:09 The match has reached half-time.
44:10 Leon Constantine is ruled offside. Ben Williams restarts play with the free kick.
43:20 Free kick awarded for a foul by John White on Leon Constantine. Free kick crossed right-footed by Ryan Valentine, save by
42:36 The official flags Kevin Lisbie offside. Adam Bartlett restarts play with the free kick.
Correction - 39:31 Jordon Mutch concedes a free kick for a foul on Kemal Izzet. John White takes the free kick.
39:31 Free kick awarded for an unfair challenge on Kemal Izzet by Jordon Mutch. John White takes the direct free kick.
38:32 Gavin McCallum has a shot on goal from outside the box which misses left.
37:31 The ball is delivered by Marc Tierney, Ryan Green manages to make a clearance.
33:47 Craig King crosses the ball, Magnus Okuonghae makes a clearance.
33:07 Gavin McCallum takes a shot.
30:56 The offside flag is raised against John-Joe O'Toole. Adam Bartlett takes the free kick.
30:47 The ball is delivered by Marc Tierney, Darren Jones manages to make a clearance.
29:59 A cross is delivered by Simon Hackney, save by Adam Bartlett.
29:34 Kevin Lisbie fouled by Ryan Valentine, the ref awards a free kick. John White restarts play with the free kick.
28:27 Darren Jones takes a shot. Save made by Ben Williams. Corner taken by Kenny Lunt from the left by-line played to the near
post, Foul by Darren Jones on Simon Hackney, free kick awarded. Ben Williams takes the direct free kick.
26:12 John White sends in a cross, Steven Gillespie takes a shot. Blocked by Ryan Green.
23:07 The referee penalises Kemal Izzet for handball. Kenny Lunt takes the direct free kick.
22:22 The ball is sent over by Simon Hackney, Steven Gillespie takes a shot. Clearance by Simon Hackney.
21:25 Unfair challenge on Leon Constantine by Kevin Lisbie results in a free kick. Adam Bartlett takes the free kick.
20:50 Ryan Valentine concedes a free kick for a foul on Kayode Odejayi. Simon Hackney restarts play with the free kick.
20:07 Gavin McCallum takes a shot. Save by Ben Williams.
19:31 John-Joe O'Toole has an effort at goal from just outside the box which goes wide of the right-hand upright.
19:07 The ball is sent over by Ryan Valentine, clearance by Paul Reid.
17:53 The assistant referee signals for offside against Leon Constantine. Ben Williams restarts play with the free kick.
15:30 Corner taken left-footed by Simon Hackney from the right by-line to the near post, Kayode Odejayi takes a shot. Clearance
made by Kenny Lunt.
Correction - 14:56 Corner taken by Simon Hackney.
14:56 Outswinging corner taken from the left by-line by John-Joe O'Toole.
12:20 Outswinging corner taken by Daniel Blanchett from the left by-line, clearance made by Kevin Lisbie. Handball decision goes
against Jordon Mutch. Ben Williams takes the free kick.
12:03 Marc Tierney crosses the ball, clearance made by Ryan Valentine.
11:09 Kayode Odejayi takes a shot. Save made by Adam Bartlett.
10:32 Unfair challenge on Darren Jones by Steven Gillespie results in a free kick. Direct free kick taken by Adam Bartlett.
9:12 Centre by Kenny Lunt, comfortable save by Ben Williams.
8:26 Steven Gillespie takes a shot. Save made by Adam Bartlett.
7:07 Craig King produces a cross, Shot from deep inside the area by Jordon Mutch clears the bar.
4:24 Gavin McCallum takes a shot.
2:08 Leon Constantine has an effort at goal from just inside the box that misses to the right of the target.
0:00 The match gets underway.
Live text and data provided by The Press Association.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.