Billy Sharp and Sander Berge scored goals in added time as Sheffield United ended Wrexham’s FA Cup run out of the league in a thrilling fourth-round replay.
Anel Ahmedhodzic put United ahead early in the second half before Paul Mullin’s penalty brought Wrexham level.
Mullin had a second kick saved by Adam Davies before Sharp scored deep into stoppage time.
Berge scored United’s third goal on the counter to set up a fifth round draw against Tottenham Hotspur.
The Yorkshire club can look forward to hosting Spurs after finally overcoming National League title contenders Wrexham after two exhilarating games.
United had demanded a stoppage-time equalizer from John Egan to secure a 3-3 draw and a restart in the original draw and they needed late goals again at Bramall Lane.
Both managers see promotion as their priority this season and with that in mind the hosts have made five changes to the original game, including a full debut for Ismaila Coulibaly.
Wrexham’s line-up showed seven changes from the side that won 2-1 at Altrincham in their previous National League fixture.
The hosts, as expected, dominated the first possession despite failing to create clear chances in the opening 10 minutes, while Wrexham looked to attack on the counter.
A good home shot saw Iliman Ndiaye play into James McAtee but his shot didn’t bother goalkeeper Rob Lainton, while an Egan header was cleared by a well-disciplined Wrexham defence.
Mullin, looking to add to his tally of eight goals in this season’s competition, tried his luck from the edge of the box with a shot that deflected off Egan.
United responded with a counterattack and McAtee cleared, but opted to go it alone rather than antagonize Ndiaye and put the ball unnecessarily wide.
Lainton, who fought back from a career-threatening wrist injury, made two crucial saves in the space of two minutes to counter a close-range effort from Ahmedhodzicć and then Sharp.
Although United looked the most likely to score, Wrexham comfortably held them off to stay in the game at the break.
Wrexham, now attacking the end with 4,700 rowdy traveling fans, started the second half with a bang.
But it was Paul Heckingbttom’s side who took the lead with Ben Osborn combining well on the right side with Ahmedhodzic, who smashed the ball past Lainton for his fifth goal of the season.
Heckingbottom’s men went in search of a second and Sharp was set up by McAtee to see his effort brilliantly saved.
That missed chance proved significant moments later as Mullin was brought down just inside the area by Ahmedhodzic.
Mullin stepped up and hammered the penalty straight through the middle for his 29th goal of the season in all competitions.
Wrexham were awarded a second penalty when substitute Oliver Norwood brought down Mullin, but on that occasion the striker was denied by an excellent save from Wales international Davies.
Mullin’s involvement was soon ended due to injury, while in the final minutes of regulation time Sharp moved close for the home side before being disallowed a goal for offside.
The game was in stoppage time when United felt they should have had a penalty when Norwood’s shot was manipulated.
The referee’s decision to wave play proved academic as a long clearance found Sharp down the left and he coolly passed Lainton.
As Wrexham looked for an equalizer that would have extended the game, they were hit on the counter and Berge scored a third goal from close range to seal the victory and lift the curtain on Wrexham’s cup adventure.
Sheffield United manager Paul Heckingbottom said:
“When it’s tense and it’s 1-1, we get that breakaway goal and I’m glad it fell on Bill.
“I have the utmost respect for them and what they do and it’s only a matter of time before they achieve their goals.
“But that doesn’t mean we were going to let them win for everyone’s fairy tales. We have to be selfish about that.
“Thank you to my players for their focus and determination to make sure we’re not on the wrong side.”
Wrexham manager Phil Parkinson said:
“What a performance from the guys. We were the better team I thought in the second half.
“I had no doubt we would respond, I felt we would and we did. We got the penalty to get us back into the game and I felt we were the team that was going to win the game.
“But the second penalty is obviously the key moment of the game. Cruelly, we lost it late, but we took a Premiership-linked team in two games until the end and that’s a huge credit for our lads.
“The resilience of the team was exceptional.”