Peter Brezovan was Brighton's penalty shoot-out hero as he broke Wrexham hearts in a pulsating FA Cup replay.
Brezovan saved Dean Keates's penalty before Craig Mackail-Smith's decisive kick secured a home tie against Newcastle for the Championship side.
Manager Andy Morrell had given the home side a first-half lead with a stunning curler into the top corner.
Brighton had offered little until sub Ashley Barnes levelled on 77 minutes with a header which forced extra-time.
The defeat was harsh on the last non-league side left in the competition, who had more than matched their Championship opponents.
Brighton fielded a strong side and Matt Sparrow was the first to try his luck on goal inside the opening three minutes when his shot from outside the area flew past Joslain Mayebi's left-hand post before Nat Knight-Percival headed wide for the home side.
But the Dragons also made a positive start and Morrell's effort from six yards out was blocked by Brezovan before they went ahead in spectacular fashion on 23 minutes.
Following a strong run down the left, Danny Wright found Morrell on the edge of the area and the player-manager's curling shot found the top right corner of the goal.
Wrexham's defence were keeping things tight at the other end, although Mayebi caused panic when he dropped the ball following a cross before gathering at the second attempt.
A spell of Wrexham pressure resulted in a long-range effort from Jay Harris which was gathered by Brezovan.
Having finished the first half strongly, Wrexham started the second period brightly and full-back Curtis Obeng forced Brezovan to save inside the first two minutes.
Wrexham were dealt a blow on 58 minutes when the impressive Wright left the field on a stretcher after dislocating his elbow, and he was replaced by the experienced Glen Little.
Brighton were finding it hard to get a grip of the game and Will Hoskins fired over the crossbar from inside the area following Will Buckley's quickly taken free-kick.
In an increasingly end-to-end match, substitute Little fired over the crossbar after good work by Ashton and Morrell, while Sparrow wasted a rare chance for Brighton when he shot wide.
The home side were pressing for the second goal but against the run of play substitute Barnes, who had replaced Alan Navarro, equalised.
Wrexham failed to clear their lines and Sparrow crossed for Barnes to head in via the post.
Brighton were now pressing for a winner and Mackail-Smith's shot flew across the face of goal before Mark Creighton was forced to make a crucial last-ditch tackle.
Joe Clarke wasted a glorious opportunity to win it for the non-league side in injury time when he headed over the crossbar from Ashton's corner.
Even so, Wrexham almost had the perfect start to extra-time when from Ashton's corner Creighton's goalbound header was pushed away spectacularly by Brezovan.
His opposite number Mayebi was also called into action soon after when he denied substitute Torbjorn Agdestein, who was through on goal.
Both sides continued to press, with Buckley's header flashing across the face of Mayebi's goal before a Harris header nearly snatched a dramatic victory in the final minutes.
Penalties were required and the decisive moment came with Wrexham's first penalty, when substitute Keates saw his effort saved by Brezovan.
Both sides successfully converted their next four penalties before Mackail-Smith hammered home his spot-kick to secure a fourth-round tie with Newcastle.
Wrexham player-manager Andy Morrell: "The lads were absolutely fantastic today and they deserve all the credit that they get and on another day we might have nicked it as well.
"It wasn't to be, but I am so proud. We had the better chances I think, but I am not going to sit here and complain.
"They are devastated down there and I have told them I don't see why they should be.
"We have just given a decent Championship team a right run for their money, I can't fault any of them."
Brighton boss Gus Poyet: "It was a very difficult game. We knew we did not start well but the cup is about getting through somehow.
"When you come here you have nothing to win and everything to lose. If you win 3-0 that's normal. If you win on penalties you are lucky.
"So it is not easy. Saying that, most of the time it is credit to the opposing team and you can see how much it means for the players.
"It was a great FA cup tie, I can imagine how Wrexham feel. They were so close to having a great game here, but that's football, sometimes it goes for you and sometimes it goes against."