Will Grigg scored twice in the last 10 minutes to save Wigan Athletic from FA Cup humiliation against non-league Fylde.
The 2013 winners were teetering on the brink of a huge giantkilling before Grigg popped up with a brilliant brace having been sent on as a substitute.
First he diverted Gary Roberts’s cross on 80 minutes, before being in the right place at the right time grab a dramatic winner five minutes later with extra-time looming.
There had been little sign of the eventful night ahead when Ivan Toney put Latics ahead on the half-hour mark.
But that was soon cancelled out by Simon Grand’s deflected effort with five minutes of the first half remaining.
And when Danny Rowe put Fylde ahead just after the hour mark, after good work from Jonny Smith, a massive shock looked to be on the cards.
Grigg, however, extinguished that dream in a flash - to set-up a third-round trip to Bournemouth in the New Year.
But Paul Cook will know his men will need to play far better if they are to extend their run in the competition, having flattered to deceive for the majority of the encounter.
The Latics boss had signalled his intention to select a strong side and, despite making eight changes, it was packed full of first-teamers.
And his side were quickly into their stride, with Gavin Massey’s early cross rolling only just in front of Toney.
The visitors also settled into their rhythm with minimum fuss, as Rowe - scorer of Fylde’s equaliser in the first game - warmed the hands of Matija Sarkic from 25 yards.
A clever corner from Max Power almost caught Fylde unaware at the near post, with Dan Burn stabbing goalwards only for Rowe to deflect it over the top.
But at the other end, Smith’s cross found Andy Bond in a good position, but the Whelley lad couldn’t adjust his feet in time and scuffed it well wide.
The basketball nature of the game continued with a goal at either end before the break.
Nice work down the left from Callum Elder laid the opener on a plate for Toney can’t miss from six yards. 1-0 to Latics.
But just 10 minutes later, a scuffed clearance from Nathan Byrne fell to Danny Rowe 15 yards out.
His firm shot was well parried out by Sarkic, but Grand was on hand to blast home from three yards.
Byrne made amends at the start of the second period when he got across superbly to snuff out a Fylde break with Rowe looking to pull the trigger.
That was the signal for movement on the Latics bench with Ryan Colclough making way for that man Grigg.
Both sides had a shout for a penalty in the space of 30 seconds, but the referee was unimpressed by Smith’s tumble for Fylde and then Toney’s for Latics.
But Fylde did have reason to shout on 64 minutes when they went ahead for the first time in the tie, with Rowe’s shot deflecting past Sarkic.
The young goalkeeper, on loan from Aston Villa, then kept Latics in it when he got across smartly to keep out a Bond effort.
Noel Hunt took over from Massey to give the home side fresh legs up top, and Latics had an equaliser within minutes.
Roberts it was who slipped the ball into the path of Grigg, who finished calmly from close range.
If that goal dashed Fylde’s hopes, their dreams were then shattered when Grigg found himself unmarked at the far post and found the bottom corner.
There was still time for a flashpoint in stoppage-time, when the referee penalised Sarkic for time-wasting and awarded the visitors a free-kick inside the box.
But Rowe’s goalbound effort was deflected wide off the wall - and Latics had just about negotiated a real banana skin.
Wigan Athletic (4-2-3-1): Sarkic; Byrne, Bruce, Burn, Elder; Perkins, Power; Roberts, Massey, Colclough; Toney.
Subs: O Evans, Thomas, Merrie, Dunkley (for Roberts, 87), Burgess, Hunt (for Massey, 73), Grigg (for Colclough, 61).
AFC Fylde (4-5-1): Lynch; Richards, Tunnicliffe, Grand, Francis-Angol; Ezewele, Bond, Finlay, Smith, Montrose; Rowe.
Subs: Taylor, Muldoon (for Ezewele, 54), Taylor, McCready, Blinkhorn (for Bond, 85), Tasdemir, Jones.
Referee: R Joyce
Star Man: Will Grigg