The League One side had looked certain to have their name in the hat for their third round, as goals in either half from Ed Upson and Conor Clifford gave the Glovers a comfortable lead.
But after dumping Wycombe out of the cup in the first round, Fleetwood had gained confidence and fought back through a Kieran Charnock header, before player-coach Milligan held his nerve in the 89th minute to force a reply.
The visitors' early dominance was rewarded on 32 minutes as Upson unleashed a thunderous shot into the top-right corner after Fleetwood had failed to clear from a corner. And they found themselves two ahead three minutes after the break as Clifford found the net following a superb through ball by Andy Williams.
That woke Fleetwood up, and their pressure paid off on 82 minutes as Charnock's header found the bottom corner following a great cross from Peter Till.
And the dramatic comeback was complete in the dying moments as Milligan swept home from the spot after Jamie McGuire had had his shirt pulled in the penalty area, forcing a replay at Huish Park.