York City secured all three points at Stockport through second-half goals from Matty Blair and Jason Walker.
Following a forgettable first half, Blair scored shortly after the break when he raced to meet Walker's cross with a powerful header.
York made it comfortable late on, when Walker converted Ashley Chambers' pass for his 10th goal of the season.
With the full-time whistle about to blow, Michael Paton's injury-time header was a mere consolation.
VIEWS FROM THE DRESSING ROOM
York City manager Gary Mills told BBC Radio York:
"We've come here and I think we've done very well. It's taken the gloss off it a little bit conceding in the last minute but that's me being a manager and the players are disappointed as well to concede that goal.
"To come back and bounce back after Tuesday which was a disappointing evening for us and be patient today I'm delighted.
"I said to them at half time the opening will come but we've got to have that extra pass. They listened and we got a fantastic three points."