Patrick McLaughlin fired in the only goal of the game to send York into the Blue Square Bet Premier play-off places with victory at Bath.
McLaughlin struck a left-footed effort into the bottom corner from the edge of the area shortly after the restart to seal the points.
Jamie Reed was twice denied by Bath keeper Glyn Garner, before volleying a third effort wide.
With victory, the Minstermen stretched their unbeaten away record to 12 games.
VIEWS FROM THE DRESSING ROOM
Bath City manager Adie Britton told BBC Radio Bristol:
"I thought for the majority of the game, other than the first 10 or 15 minutes, we just dominated it.
"It typifies our season in a way. From box to box, our football was superb and we passed the ball really well, got in great positions - you can't really fault them.
"We defended well all night and we gave the ball away once it ended up in the back of the net.
"It's disappointing but that's pretty typical of what we've done all season."
York City manager Gary Mills told BBC Radio York:
"We're relieved. It's a difficult place to come and I thought we started well then made it easy for them. I said a few words at half-time that we needed a bit more tempo and winning mentality.
"I could only see a nil-nil if we carried on the way we were. I think the first five or 10 minutes have won us the game in the second half.
"We got three points and that was the most important thing to put us back into the top five."