Stockport denied Brackley Town a first FA Cup third-round appearance by beating the National League North outfit 3-1 at Edgeley Park.
But after coasting into a 2-0 lead inside 18 minutes, the League One side suffered a major second-half scare from their sixth-tier opponents, who started the day 76 places below them in the pyramid.
And it needed substitute Tanto Olaofe’s 86th-minute strike to break the non-league side’s resistance and make sure of County’s place in Monday’s draw.
The Northamptonshire visitors were denied the opening goal by Corey Addai’s 13th-minute save from Matt Lowe.
But County, fourth in League One, then took a firm grip on the tie and Will Collar fired the Hatters ahead two minutes later from Kyle Wootton’s assist.
The scorer then turned provider, crossing for Wootton to head in after 18 minutes.
County, with 14-goal loan star Louie Barry rested, then missed a host of chances before the break.
That profligacy almost came back to bite them as Callum Connolly’s bizarre 55th-minute own goal put Brackley back into contention.
Connolly’s 45-yard back pass was too strong for goalkeeper Addai to keep out.
Addai saved a 77th-minute effort from Lowe and was grateful to see Alfie Bates’ follow-up disallowed for offside.
But as Brackley continued to press for an equaliser, they were caught out when Tayo Adaramola crossed for Olaofe to score.
Subscribe or register today to discover more from DonegalLive.ie
Buy the e-paper of the Donegal Democrat, Donegal People's Press, Donegal Post and Inish Times here for instant access to Donegal's premier news titles.
Keep up with the latest news from Donegal with our daily newsletter featuring the most important stories of the day delivered to your inbox every evening at 5pm.