Kevin Ellison’s injury-time header gave Morecambe three points to settle a crazy, breathless encounter at the Globe Arena.
The Shrimps had seemed set for a fourth straight defeat when they trailed 2-0 at half-time and 3-2 on 84 minutes.
However, Vadaine Oliver and Callum Lang (2) got them on level terms before Ellison settled matters in added time.
Morecambe had made five changes from the side beaten so comprehensively by Notts County on Boxing Day.
Out went Alex Kenyon, Garry Thompson, Adam Campbell, Mitchell Lund and Elliot Osborne with Luke Conlan, Max Muller, Michael Rose, Ellison and Lang coming in.
Needing a good start, the Shrimps had anything but as they presented their visitors with a belated Christmas gift.
Conlan and Steve Old got in each other’s way, allowing Gray to burst into the area and fire past Barry Roche with only 23 seconds gone.
Khan had a shot blocked by the Morecambe defence before the Shrimps came within inches of a similarly giftwrapped goal.
Oliver’s shot from 30 yards seemed optimistic enough; certainly to Yeovil keeper Artur Krysiak who stood and watched the ball go past him - only to cannon back off his right-hand post.
The Glovers capitalised on their good fortune four minutes later when Khan doubled their lead, curling a shot over Roche from the right-hand side of Morecambe’s penalty area.
Francois Zoko headed wide as the Shrimps played catch-up but without creating anything in the way of genuine chances.
They should have at least worked the keeper when Aaron McGowan’s cross found Oliver but he failed to control the ball when well placed and the chance was gone.
It could have been worse as the already cautioned Muller was given a final warning, necessitating his substitution five minutes before half-time.
The Shrimps came into the game more after the break with Andy Fleming shooting wide, Sam Lavelle twice chancing his arm from corners and Oliver seeing his shot held by Krysiak.
Rose saw a free-kick blocked on its route to goal before Oliver pulled one back on 72 minutes.
Krysiak should have saved Lang’s shot, Ellison’s follow-up was cleared off the line and Oliver’s subsequent effort was deemed over the line.
It wasn’t a thing of beauty but it gave the home side a lifeline they desperately required.
Seven minutes later and they were level as Lang headed home from Rose’s cross.
However, it was 3-2 to Yeovil on 84 minutes when Roche pushed Tom James’ free-kick behind, only for Omar Sowunmi to head home from the resulting corner.
Nevertheless, Morecambe went downfield from the restart, and when Ellison’s shot was blocked, Lang took a touch before finishing calmly.
Both sides poured forward in search of a winner and it was Ellison who provided it, heading over Krysiak in the second of six added minutes.
There was still time for James to have a free-kick deflected behind before the final whistle brought some semblance of normality to an abnormal second half.
Morecambe: Roche, Muller (Kenyon 40), Lavelle, Old, McGowan, Fleming (Thompson 86), Rose, Conlan, Lang, Oliver, Ellison. Subs not used: Nizic, Campbell, Lund, Osborne, Jordan.
Yeovil Town: Krysiak, Mugabi, N Smith, Sowunmi, James, Gray, Worthington, C Smith, Khan (Green 74), Zoko (Olomola 70), Surridge. Subs not used: Maddison, Davies, Nelson, Santos.
Referee: Darren Handley.