York City's seven-game unbeaten run was ended by runaway leaders Accrington Stanley who scored twice in three second-half minutes.
City took the game to the leaders from the kick-off and inside the opening minutes Emmanuel Panther's long-range shot was blocked before Mark Convery's cross picked out Andy Bishop and his downward header was taken by keeper Rob Elliot at the second attempt.
The Minstermen showed quality from their free-kick routines and from one Darren Dunning saw his curling effort tipped over for a corner. From Convery's inswinging corner, Neal Bishop then got the faintest touch and Clayton Donaldson headed home from close range.
Stanley hit back strongly and Gary Roberts twice went close before City's top scorer Andy Bishop had the chance to double City's lead. He cut inside his marker in the box but Elliot came out and spread himself well to make a vital block.
Accrington equalised on 35 minutes when Roberts' cross was flicked on by David Brown for Paul Mullin to chest down and shoot past Chris Porter from eight yards.
In a pulsating game, City moved ahead just before the break when Donaldson's pace took him to the byline and his low cross was hammered home by top scorer Andy Bishop from close range.
Within minutes of the restart, Roberts' shot from the left edge of the area struck Jamie Price's hand and a penalty was awarded which Brown converted.
James Dudgeon was unlucky for City when his header from a corner struck the post. Then Stanley scored twice in three minutes to wrap up the game. Firstly Mullin headed home Roberts' corner at the near post, then Mullin set up Ian Craney from a throw-in and the midfielder fired home from 15 yards.
City's man-of-the-match Donaldson earned a stoppage-time penalty when he was upended in the area but keeper Elliot saved Andy Bishop's spot-kick diving to his left.