Jason Walker scored the only goal of the game to inflict a fourth successive defeat on Accrington as York won 1-0 at the Crown Ground.
The forward fired a bobbling ball past Ian Dunbavin with seven minutes left for his fourth goal of the season.
In the early exchanges Matty Blair's 20-yard strike was not far off target while a Walker effort was blocked by George Miller.
City appealed that Clarke Carlisle's scrambled shot was over the line as Dunbavin dived low but referee Darren Drysdale waved away the appeals.
Lee Molyneux had a cross finger-tipped over by keeper Michael Ingham and at the other end Dunbavin kept out Blair's deflected blast from 18 yards.
York were creating the better chances in the second half but it looked like it would peter out to a goalless draw until Walker finished a scrappy move and earned his side the three points.