Kaid Mohamed's extra-time winner at a foggy Edgar Street broke Hereford hearts to send Cheltenham through to the third round of the FA Cup.
Mohamed's header earned the Robins a lucrative, televised home tie against Premier League Everton on 7 January.
Cheltenham went ahead from Shaun Harrad's controversial penalty after Andy Gallinagh had been penalised for his challenge on Jermaine McGlashan.
But Sam Clucas's shot squirmed home to level the tie on 74 minutes.
Everton boss David Moyes was at Edgar Street to watch his side's third round opponents
Hereford boss Martin Foyle was part of the Port Vale side that dumped Everton out of the FA Cup 16 years ago, even scoring at Goodison Park.
But, despite another spirited display from his Blue Square Bet Premier side against their League Two opponents, his hopes of setting up a rematch ended.
In a tense first half low on drama, perhaps influenced by the size of the prize on offer, there was little cause for excitement.
Hereford were not helped by 11-goal top scorer Ryan Bowman limping out of the tie after just 15 minutes with a medial knee ligament injury.
But the Bulls did have a Clucas shot saved low down by visiting goalkeeper Scott Brown, while Will Evans scuffed another left-footed shot just wide.
For Cheltenham, Darren Carter had a 25-yard free-kick comfortably saved low by James Bittner, who then had to be alert to tip over McGlashan's looping header.
But the game erupted into life in first-half injury-time.
“It's a deflated dressing room. We're devastated to have been just six minutes from penalties”
Martin FoyleHereford United manager
Brown had pulled off a brilliant save to deny Clucas's left-foot shot and Cheltenham then went straight down the other end and won a penalty.
Cheltenham old boy Gallinagh was adjudged to have fouled McGlashan and Harrad powered the resulting spot-kick straight down the middle.
As the fog descended on Edgar Street, it seemed Hereford's hopes were starting to disappear. But Clucas's scrambled effort with 16 minutes left slid inside Brown's right-hand post to get them back on level terms.
Cheltenham nearly won it late on when Bittner saved well from Jake Taylor, but, with the fog worsening, the game went to extra-time.
And the visitors finally won it six minutes from time when, from Billy Jones's superb left-wing cross, substitute Mohamed rose at the near post to steer his header just inside Bittner's left post.
VIEWS FROM THE DRESSING ROOM
Hereford United boss Martin Foyle told BBC Hereford & Worcester:
"It's a deflated dressing room. We're devastated to have been just six minutes from penalties.
"The lads have given me absolutely everything tonight and they're out on their feet. And, to add insult to injury, Ryan Bowman has tweaked his medial ligaments.
"It all changed for us in 60 seconds just before the break. Their keeper pulled off a fantastic save from Sam Clucas and then they go down the other end and score.
"Was it a penalty? I'd like to see it again. But Andy Gallinagh has got the wrong side and, if the lads' bought a penalty then he's bought a penalty. That's cup-tie football for you."
Cheltenham Town manager Mark Yates told BBC Radio Gloucestershire:
"When the draw was made, I said we wanted someone from the league below at home, but the worst team we could have got was Hereford.
Cheltenham showed quality - Yates
"We've got a terrible record against them and I hate coming here. It took me an hour and a half to get here and I only live 30 miles away.
"There was a bit of pressure on us as the chairman was ramming it down my throat about just how much we needed the TV money in the next round. But the players can go and enjoy their big day now and they deserve it.
Cheltenham forward Shaun Harrad on the penalty decision:
"I was only 10 yards away and you could see immediately that it was a penalty. We'd have been disappointed if it hadn't been given.
"He's nutmegged him and brought him down. It was a clear penalty for me.
"[The booing] was just a bit of sour grapes in the end as he was a real threat to them first half."
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.