Wing-wizard Gary Roberts and striker Paul Mullin were Accrington's heroes as they surprised fellow title-chasers York.
Former Liverpool schoolboy Roberts netted for Stanley in the first half, before Andy Bishop headed visiting York level shortly after the hour mark.
But cue Mullin, now in his fifth season with Stanley. The experienced centre-forward restored the lead in the 67th minute with a bullet shot which beat York keeper Chris Porter all ends up.
Accrington were two places and two points behind York in the table at the start of the day, but victory for John Coleman's side has seen them close the gap on their fellow high-fliers who, following their defeat and with Exeter City 3-0 winners over Tamworth, drop from second to fourth in the Nationwide Conference table.
In fairness, Colemen's men were the better starters, but it was not until the 15th minute that they threatened Porter's goal.
Ian Craney found time and space to unleash a powerful shot, but Porter saved well to deny him.
York's first chance game ten minutes later courtesy of some clever play from Darren Dunning.
He forced Stanley keeper Darren Randolph - the 18-year-old on-loan from Charlton Athletic -to make a good save to keep the scores level.
It proved very important as the home side continued to dominate and, having had most of the possession, eventually broke the deadlock through Roberts.
With a minute left until the interval, Roberts unleashed a shot which beat Porter to give his side a slender advantage.
The restart saw Accrington control the game once again, but Bishop equalised in the 63rd minute, heading home from a Mark Convery free-kick. Randolph had no chance of stopping the close-range effort.
And York should have taken the lead, only for Levent Yalcin to fire over three minutes later.
But his miss proved costly as Mullin restored Stanley's advantage, firing home having received the ball from Leam Richardson's free-kick.
Bryan Stewart fired wide as the Minstermen went in search of a share of the spoils, but Stephen Jagielka should have given Accrington a 3-1 victory in stoppage time.
However, although he shot over, Coleman's charges had done enough to deservedly grab all three points.