Sam Dalby and Paul Mullin scored in either half as Wrexham saw off League Two rivals Mansfield Town in the FA Cup first round in an enthralling game at a rain-soaked Field Mill.
Dalby's fierce drive gave the visitors a first-half lead which would have been greater had it not been for the heroics of keeper Christy Pym.
Mullin doubled the lead against the run of play and although Rhys Oates replied a minute later, Wrexham saw out the game.
Phil Parkinson's men advance in a competition in which they reached the fourth round last season.
It was Mansfield's second loss of the season in all competitions but significantly a second successive cup loss after their Carabao Cup exit at the hands of Port Vale in midweek.
Nigel Clough's side enjoyed a promising opening 10 minutes with Oates' low shot well saved by keeper Arthur Okonkwo and ex-Wrexham player Davis Keillor-Dunn fired wide.
Another Keillor-Dunn effort was saved by Okonkwo before Oates shot wide while at the other end Dalby was denied by Pym.
But there was no denying Dalby when after being played in by Andy Cannon he unleashed a shot into the top corner to put Wrexham ahead.
Wrexham were enjoying their best spell of the game with a Dalby effort from close range turned on to the bar by Pym.
Elliot Lee tried his luck at goal with an effort that was well saved by Pym, who again denied dangerman Dalby from the loose ball before saving from Mullin late in the half.
Mansfield began the second half on the front foot with Keillor-Dunn missing a great chance from close range before firing a free-kick into the side-netting.
Despite Mansfield pressure, it was Wrexham who doubled their advantage when Dalby picked out Mullin with plenty of space in the box to place the ball past Pym.
But the Stags responded immediately when Oates beat Okonkwo with a fierce drive from the edge of the box to give Clough's side a glimmer of hope.
Late on Keillor-Dunn's shot flew past the post much to Wrexham's relief, as the Welsh side held on to progress to the second round.
Wrexham manager Phil Parkinson told S4C's Sgorio: "I'm just so proud of the boys tonight, in those conditions against a top team in Mansfield.
"Some of the chances we created in the first half, we hit the bar, had a couple of one-on-ones, but couldn't get that second goal.
"Couple of penalty appeals too, I thought the ref gave us very little on the night but that is a colossal victory for us."