Wanderers suffered a painful FA Cup exit as a two-goal lead twice inside the opening half an hour wasn’t enough to kill off National League County.
Stockport gifted Wanderers two of their goals after a deflected Elias Kachunga strike inside the first two minutes had given Ian Evatt’s men a dream start to their first-round replay.
County defender Ash Palmer then scored an own-goal and even after Paddy Madden had briefly halved the deficit from the penalty spot, Wanderers were handed a third goal for Amadou Bakayoko by another defensive mistake from the non-leaguers.
But Wanderers weren’t good enough on the night to capitalise as County hit back just before the break and then after pushing almost constantly for an equaliser finally got it in the 85th minute through Palmer.
There looked only one winner at that stage and so it proved as the Hatters clinched a notable victory five minutes into extra time with a second goal from the impressive Scott Quigley to book a second-round trip to Rotherham and send Wanderers crashing out.
MJ Williams was a rare absentee from the Wanderers’ line-up through illness, with Eoin Doyle also not risked with the calf strain that has kept him out since the first meeting between the sides.
And their experience, composure and leadership was missed in a helter-skelter tie that burst into life with barely 60 seconds gone.
Kachunga scored his first Wanderers’ goal in the 2-2 draw 10 days earlier and was on target again thanks to a lung-bursting run from his own half which ended with a shot deflected past County keeper Ethan Ross.
And Wanderers then quickly doubled their lead in the perfect start for Evatt’s men.
Again County were forced onto the back foot and when Josh Sheehan crossed low into the box, Palmer sliced the ball into his own net.
That threatened to make it a long night for the hosts - whose main focus is to try and win promotion back to the Football League - but they responded impressively in an effort to stay in the contest.
Former Wanderers’ skipper Antoni Sarcevic almost pulled a goal back with an effort well saved by Joel Dixon and with 24 minutes gone the hosts did make it 2-1 via the penalty spot.
Lloyd Isgrove tripped Ryan Rydel just inside the box and Madden kept his cool to slot home the spot-kick.
The momentum might have been with County at that stage but instead they gifted Wanderers another goal when Bakayoko’s pace again worried the Hatters’ back line into a fatal error as Mark Kitching headed the ball past Ross for Bakayoko to sprint in and claim the final touch.
That should have made life easier for Wanderers but again they allowed County a route back into the game just before the end of a breathless first half as Quigley followed up his goal in the first encounter by steering a fine header inside the far post.
Sheehan’s unfortunate withdrawal through injury then prompted a change in personnel and formation by Evatt as Will Aimson became one of three central defenders with more advanced roles for Isgrove and Declan John.
But the move didn’t immediately stem the tide as Wanderers failed to hold onto the ball long enough to gain any measure of control at the start of the second half.
Quigley remained a threat as he fired over from the edge of the box but it looked as though the Whites were beginning draw the sting of the home side as the game entered its final quarter.
It still needed some last-ditch defending to keep County out, though, and with just five minutes to go the Whites cracked again as Palmer gained salvation for his earlier own-goal by powering home a header from a corner.
There was still time for Kachunga to be booked for diving after he had been pulled back outside the box before he volleyed just over the top as Wanderers looked to repair the damage before going into extra time.
The respite didn’t last long, though, as five minutes into the extra half-hour County went ahead for the first time on the night.
Again Quigley gave the Whites’ back line the slip and after turning onto Madden’s ball into the penalty area lifted a shot beyond former Barrow team-mate Dixon.
Wanderers tried to respond with an Isgrove cross flashing across the face of goal at the start of the second period of extra time.
But the Whites’ opportunity had gone and with virtually the last kick of the game, Olly Crankshaw broke clear to slot home a fifth goal which prompted a pitch invasion and a sour end to a bleak night.
Wanderers: Dixon; Isgrove, Santos, Johnston, John (Gordon 100); Thomason; Kachunga, Sheehan (Aimson 45), Lee, Afolayan (Amaechi 77); Bakayoko (Delfouneso 73). Substitutes: Gilks, Baptiste, Gordon, Tweedley, Henry, Pettifer.
Booked: Sheehan, Isgrove, Kachunga, Amaechi
Stockport County: Ross; Southam-Hales (Barclay 103), Keane (Minihan 90), Palmer, Kitching; Collar (Raikhy, 68), Croasdale, Sarcevic (Crankshaw 75), Rydel; Quigley (Reid 106), Madden. Substitutes: Hinchcliffe, Hogan, Jennings, Pye.
Booked: Madden, Palmer
Referee: Samuel Barrott