Two second-half goals ensured York maintained their play-off push with victory at Alfreton.
York almost went ahead after the break but Jamie Reed, who had been brought down in the box by Darran Kempson, saw his penalty saved by Jon Stewart.
The Minstermen took the lead midway through the second half when Matty Blair fired home from inside the area.
Lanre Oyebanjo sealed York's win, converting Patrick McLaughlan's cross into the box.
VIEWS FROM THE DRESSING ROOM
Alfreton manager Nicky Law told BBC Radio Derby:
"No complaints there, we were beaten by the better team. I think if you look at the team sheet before the game, you can see the quality they've got.
"We didn't set about the game in the way we normally do. I'm not making excuses but we did look tired. Emotionally and physically, the last eight, nine, ten games, the players have given their all and they should be proud of their efforts.
"If you go back two months, who would have thought we'd be in this position now? I don't think many people. We've come against a quality side who've got a lot of strength and depth and today we weren't good enough and we have to be honest about that."
York City manager Gary Mills told BBC Radio York:
"I thought from start to finish today we dominated the game.
"We played more like ourselves and I think it's been a while since we played like that.
"Just for a split second you know, Jamie Reed misses a penalty and then we miss two or three other chances in the second half and you think 'is it going to be?'
"And then as he does, Matty Blair comes in with another goal to sort of get us going, but thoroughly deserved and a big win for us."