Halifax old boy Jamie Murphy gifted his former employers the points with a terrible injury-time back pass that dented his current side's play-off hopes.
Defender Murphy's pass was intercepted by Town youngster Andy Farrell and the teenager held his nerve to round Shrimps keeper Craig Mawson to slot home the winner.
Murphy and Mawson - another former Halifax player - were left sitting on the floor shaking their heads in disbelief as Farrell darted round the back of the net with his shirt off to celebrate with jubilant home fans.
The relief around the stadium was palpable because home supporters had watched their side dominate Morecambe and only had a flurry of undeserved bookings and a sending-off to show for their efforts.
Fussy Manchester referee Chris Harwood booked four Halifax players, five Morecambe players and gave the Shaymen's Phil Clarkson his marching orders after 77 minutes for a second bookable offence.
It was not a dirty game and most of the yellow cards were undeserved. The bookings, however, confirm Halifax's status as the Conference's bad boys, they have totted up more than 50 bookings and have had ten players sent off with barely half the season gone.
Mawson kept the home side at bay for long periods and twice pulled off brilliant saves with his legs to stop Halifax taking the lead.
He reacted sharply to deny Lewis Killeen after 30 minutes with his trailing right leg after the Morecambe defence had been split open by a devastating one-two between Killeen and Steve Bushell on the edge of the box.
And Mawson stopped a certain goal on 59 minutes when he denied substitute striker Brian Quailey with his legs.
Quailey was brought on at half time to replace ineffective Ian Fitzpatrick and the burly frontman immediately set about causing the visitors all sorts of problems at the back.
Quailey was instrumental in helping Chris Wilder's men force six corners in a blistering 15-minute spell of pressure at the start of the second period, but Morecambe held firm.
It looked as if the Shrimps were going to leave West Yorkshire with a point until Murphy's error at the death.