HALIFAX hearts were broken by substitute Wes Baynes' spectacular goal two minutes into stoppage-time as Wrexham won through to the first round.
Neil Aspin's side, unbeaten in their previous 15 games, seemed destined for a replay until Baynes crashed a speculative 25-yard shot in off the underside of the bar with two more minutes of added time left.
Blue Square Premier representatives Wrexham had the better of the first half, Gareth Taylor heading against the bar and proving a constant threat from set pieces. Halifax defended well but they had to wait until 10 minutes before the interval for their first corner. Tom Baker's flag kick was helped on by James Riley but Steve Payne's downward header flashed wide.
Goalkeeper Jonathan Hedge pulled off an excellent save on the hour from substitute Adrian Cieslewicz, whose shot was arrowing towards the top corner.
The UniBond First Division North Shaymen almost took the lead in the 84th minute when goalkeeper Chris Maxwell dropped a ball from Baker but Payne's volley was too high. Baker had a shot saved before Baines's winning strike and Nicky Gray was denied an equaliser by Maxwell.
Town manager Neil Aspin said: "The players can hold their heads high. I am obviously disappointed to lose the game but they can take a lot of credit from that performance."
The match attracted a bumper crowd of 2,843 to The Shay.
FC Halifax Town: Hedge, Hardy, Codman, Payne, Crossley, Riley, Gray, Phelan, Dean, Baker, Marshall. Unused substitutes: Senior, Harrison, Hotte, Penfold.
Wrexham: Maxwell, Obeng, Assoumani, Mike Williams, Jones, G Taylor, Marc Williams, Sinclair, Fleming, McCluskey, Smith. Unused substitutes: Westwood, Taboubi, N Taylor, Spann, Ciesiewicz, Baynes, Sakho.
Referee: J Simpson (England).