Mansfield manager Nigel Clough praised the character of his side after they overcame Accrington 3-1 on penalties after the game finished 2-2 after extra-time.
Stanley opened the scoring after 27 minutes through Everton loan winger Isaac Heath before second-half substitute Will Evans headed home for the League One Stags after 53 minutes.
Paddy Madden put the Reds back in front after 102 minutes before Kyle McAdam forced the ball home in the second minute of added time in the first half of extra-time.
Then came the penalties and Stags keeper Owen Mason was the hero, saving three of Stanley’s spot-kicks.
Clough said: “It as an unbelievable cup tie, with torrential rain, extra-time, penalties, coming from behind twice.
“I got the formation wrong in the first half, we changed it at half-time and we were much better.
“It was about character today – the cup-tie, the conditions, it was all about the character of the team.
“You need people to step up with the conditions and the situation we had going into the game, with all the injuries, and everyone did.
“They weren’t three lucky saves from Owen for the penalties, they were three really good saves.
“In the end we are through and that’s all that matters and we can look forward now. I wish we could have thanked all the fans individually who came today, in those horrendous conditions.”
Stanley boss John Doolan said: “We are feeling flat but I couldn’t ask any more of the lads, I am proud of our performance.
“We have got to take a lot of credit for going ahead twice, scoring two really good goals, so it was frustrating to lose but to take an established League One side to penalties, our lads gave a really good account of themselves.
“Penalties are a lottery. Ours were good penalties but their keeper has made good saves and got them through to the next round.”
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.