Andy Bishop's penalty two minutes from time was smashed home to give York City victory and ended Morecambe's eight match unbeaten run.
After going ahead, City keeper Chris Porter brought off two superb saves to earn caretaker boss Viv Busby his first clean sheet in 10 attempts.
Inside the opening five minutes both keepers made great saves using their outstretched legs, Porter blocking Danny Carlton's effort and Adam Sollitt denying Bishop.
City had a great chance to go ahead on 27 minutes when the referee awarded a debatable penalty after Jon Maloney was adjudged to be tripped in the box following Darren Dunning's free-kick.
Dunning took the spot kick himself sending the keeper the wrong way but the ball struck the base of the post and was cleared.
After the break on-loan Rob Constable hit a fierce free-kick from 30 yards which Sollitt took at the second attempt.
The Leeds United teenager then set up Dave Merris but his effort was pushed around the post for a corner.
Morecambe hit back when Wayne Curtis unleashed a cracking drive from 25 yards which struck the bar.
Moments later, Carlton's flashing header struck the bar once again before being cleared to safety.
On 88 minutes City were awarded a second penalty when Sollitt brought Bishop to the ground on the edge of the area.
Bishop dispatched the penalty with great confidence high to Sollitt's left.
At the death City keeper Porter ensured victory with two breathtaking saves.