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."
Bath City 01 Garner 02 Simpson 15 Preece 26 Gallinagh (Watkins - 55' ) 03 Stonehouse 07 Murray (Hogg - 75' ) 08 Connolly 16 Canham 19 Burnell 21 Russell (Egan - 88' ) 09 Cook Substitutes 04 Rollo 11 Hogg 18 Watkins 20 Egan 41 Smith York 24 Ingham 02 Oyebanjo 03 Meredith 04 Smith 23 Doig 17 Blair 19 Brown (Parslow - 78' ) 20 Challinor 26 McLaughlin 07 Reed (Blinkhorn - 90' ) 10 Chambers (Moke - 83' ) Substitutes 06 Parslow 13 Bopp 15 Tonne 18 Moke 21 Blinkhorn