York downed 10-man Hayes and Yeading to move up to fourth place in the Blue Square Bet Premier.
Lanre Oyebanjo turned in Patrick McLaughlin's cross from close range to give the hosts the lead.
Dan Spence then saw red for a second bookable offence following a challenge on Jon Challinor.
The Minstermen made sure of the points late on when Jason Walker, who was brought down by Steve Arnold, scored from the spot.
VIEWS FROM THE DRESSING ROOM
York City manager Gary Mills told BBC Radio York:
"Every game is going to be like that now. Teams are going to make it difficult for us.
"We had to be patient and as much as we'd like to score a couple of goals in the first 20 minutes, if we have to be patient and get them whenever, then we'll do that.
"It's about coming away with the three points.
"It's about scoring goals and keeping a clean sheet and we've done that again."