Yoann Arquin grabbed a 92nd-minute winner as Hereford knocked Uwe Rosler's Brentford out of the Carling Cup.
Sam Saunders, Clayton Donaldson, Shaleum Logan and Karleigh Osborne all tested home keeper Adam Bartlett as the Bees dominated the first half.
But Arquin settled the tie from six yards in stoppage time following good work by Joe Colbeck.
Brentford have now been knocked out in the first round in seven of the past eight seasons.
VIEWS FROM THE DRESSING ROOM
Hereford manager Jamie Pitman told BBC Hereford and Worcester:
"We came under the cosh in the first half but we rode out the storm and we've managed to nick one at the end.
"Pre-season was about getting them fit and I would say that we finished the stronger in the end.
"That is credit to us as a coaching staff and credit to the players for the hard work that they have put in."