Playing some neat attacking football, Wrexham were well on top and there only looked to be one outcome.
Wrexham were cruising and were well in charge until they were reduced to ten men on 58 minutes when last man Steve Evans was shown a straight red card and Southport equalised from the penalty spot.
But that turned out to be the turning point as Southport came more and more into the game.
Southport had offered little in front of goal but the visitors grew in confidence, creating the chances that almost led to a winner in normal time.
And Wrexham went into extra-time with nine men after the impressive Sam Williamson was harshly red carded, while Southport were left with ten men following an elbowing offence.
And uncertainty in the Reds' defence led to Southport's winner in the first period of injury time.
Manager Dean Saunders describing the referee's handling of the game as farcical was justified.
That contributed to Wrexham's downfall, and the Reds will look back on the decision to award the penalty just before the hour mark of where it started to go wrong.
Wrexham, having twice been knocked out of cup competitions this term by teams from lower divisions including Eastwood Town in the FA Cup, now entertain fellow Blue Square Premier outfit Mansfield Town in the FA Trophy first round at The Racecourse on Saturday.
Saunders had promised to make changes to give players who have not featured in recent weeks a run-out, and also give some of his 'regulars' a rest.
The starting line-up showed five changes with goalkeeper Anthony Williams handed a first appearance of the season, while Steve Evans and Christian Smith - normally a midfielder - took over in the centre of defence.
Tom Kearney, a second half substitute in Saturday's win against Kettering following weeks of inactivity, was named in midfield alongside Levi Mackin.
And there were also places on the substitutes bench for long term injury victims Kyle Critchell and Andy Fleming.
Wrexham made the running from the first whistle and Mackin shot over from 25 yards on five minutes, and Jon Brown went wide after getting a second bite of the cherry when he latched on to Jefferson Louis' flick-on.
Nathan Woolfe's free-kick dropped wide of the target and Brown fired across goal following neat build-up play from the Reds.
Despite enjoying the majority of the possession, and getting into some decent positions, Wrexham had not had a clear cut chance of goal.
Louis did strike the bar following a corner but his effort would not have counted because the whistle had been blown for an offence in the area.
Wrexham kept pressing and Mackin's 29th minute low drive from 20 yards when a corner was only partially cleared was gathered by keeper Tony McMillan.
And the goal Wrexham had been threatening came three minutes before the break.
Woolfe threaded a pass through for Marc Williams who made his way towards goal and rounded McMillan before slotting into an empty net.
That was Williams' last telling contribution as he was replaced by Patrick Suffo for the start of the second half.
Strike partner Louis could have made it 2-0 just two minutes after the restart when he was put through on goal but his low shot was blocked by McMillan.
Southport immediately went up the other end and with his side's first attempt on goal, Mark Duffy pulled his effort wide.
Everything was going smoothly for Wrexham but Southport equalised in the 58th minute after finding a way through the Reds' back line.
Substitute Steve Daly closed in on goal but was brought down from behind by Evans who was shown a straight red card, and the striker converted the resulting penalty.
Buoyed by the goal, Southport looked a different side and Alan Moogan's drive was deflected narrowly wide.
The visitors almost took the lead in the 75th minute when Shaun Gray was denied by Anthony Williams and substitute Matty McGinn failed to turn the ball home from close range with the goal at his mercy.
Southport should have gone ahead in the final minute but an unmarked Daly prodded McGinn's dangerous centre wide with just Williams to beat.
However, Wrexham were reduced to nine men in the first minute of injury time when Sam Williamson was shown a controversially straight red card following a challenge on Duffy.
But Southport finished normal time with ten men when Moogan was dismissed for elbowing substitute Fleming.
With the game taken to injury time, Daly fired wide with just Anthony Williams to beat, but the striker made no mistake on 96 minutes.
Robbie Booth's cross to the back post was not dealt with by Anthony Williams and Daly nodded home from close range.
Fleming struck the underside of the bar in the 109th minute from outside the area but despite one last rally, Wrexham failed to come up with a leveller and Southport went through to a last eight against either York City or Barrow.