The Minstermen started the match with a high tempo and they went close early on with Lewis Montrose's effort going wide of Barry Roche's goal.
Jack Sampson's low effort in the 17th minute sparked the visitors into life with Michael Ingham having to tip Tony Diagne's powerful header over the crossbar.
The breakthrough finally came in the 30th minute when Ryan Jarvis scored his ninth goal of the season for the hosts. The striker was on hand to fire high into the net from close range after Morecambe had failed to clear Michael Coulson's corner.
On the hour mark York almost gave themselves a crucial two goal lead with Keith Lowe heading against the post from Luke O'Neill's free kick.
Morecambe had the chance to level the scores in the closing minutes but Ingham saved well low down from Jack Redshaw's header as York held on for three crucial points.