A goal in either half gave Morecambe the spoils in this Conference War of the Roses.
Michael Twiss and Gary Thompson were the Shrimps' goal heroes in a game that they looked to have won comfortably until York substitute Levent Yalcin scored a dramatic last-minute goal to cause the home side a few nervous moments at the death.
The opening goal was a nightmare for York centre-back Gary Pearson. In the 11th minute he received the ball from his keeper David Stockdale but then played a lazy, short pass that was cut out by Wayne Curtis.
He fed Michael Twiss to his left and the Shrimps star made no mistake with a glorious finish.
York hit back with Darren Dunning skimming the crossbar with a stinging 30-yard drive and Adam Sollitt producing an excellent save to deny Lee Nogan's close-range header.
However, it was Morecambe who had the better chances to add to their lead. In the 64th minute Chris Blackburn's header was cleared off the line by Dave Merris before Danny Carlton headed a cross from the excellent Jamie Heard against the outside of the right-hand post.
The Shrimps should have added to their lead in the 72nd minute when Chris Brass brought down Carlton and the referee had no hesitation in pointing to the spot. Kieron Walmsley took the spot-kick but saw his effort well-saved by Stockdale.
Stockdale was in action again with a fine flying save to his left from Garry Hunter's volley but the teenager could do nothing to deny the Shrimps a second three minutes from time.
Carlton did well again as he threaded a ball through to Thompson and he kept his cool to slot home his first goal of the season.
As Morecambe celebrated York hit back with a stunning goal. Turkey's Under-20 international Yalcin beat Sollitt with a 30-yard wonder strike - his first goal for the Minstermen.
Unfortunately for Brass' side it was too little too late as they went down to their fourth away defeat of the campaign.