Crewe extended their unbeaten run to nine games and kept up their hopes of a League Two play-off place with victory at Hereford.
The Bulls, who now sit bottom of the Football League, saw Ryan Green rifle a shot just wide and Delroy Facey denied by keeper Steve Phillips.
Billy Bodin shot wide and then headed over for the visitors, while Ashley Westwood saw a free-kick loop wide.
Luke Murphy danced through two defenders to fire in the winner.
Crewe now sit just one point behind seventh-placed Oxford, although they have played a game more.
Hereford are now two points from safety, lying bottom with 35 points.
VIEWS FROM THE DRESSING ROOM
Hereford United manager Richard O'Kelly told BBC Hereford & Worcester:
"Today was an excellent performance, it was the best since I've been here.
"I'm immensely proud of the players and how they performed today. It's just that little bit of luck that makes a difference.
"James McQuilkin and Richard Peniket have come in and done themselves no harm at all. We have a group of players who are all pushing each other."