Dundalk survived a major scare at Ferrycarrig Park as Robbie Benson's penalty in extra-time secured their place in the Extra.ie FAI Cup quarter-finals at the expense of Wexford.
Having been second best for long periods of the game, Stephen O’Donnell’s side took the lead against the run of play on 38 minutes when David McMillan slotted home.
Ian Ryan’s side had been exploiting Dundalk’s high line to good effect and turned the game on its head in 11 second-half minutes as Luka Lovic equalised before Ger Shortt fired them ahead.
A first goal for his home town club from Ryan O’Kane secured extra-time for the Lilywhites, who were left breathing a sigh of relief when Benson slotted home 10 minutes from the end to seal the win.
Wexford started on top, posing their Premier Division opponents plenty of questions on the break, but it was the visitors who fashioned the game's first chance of note on 14 minutes when Joe Adams released McMillan on the left but his effort was easily saved by Alex Moody.
Dundalk then had their first major scare three minutes later when Conor Crowley’s corner was flicked on by the head of Shortt, with Greg Sloggett having to turn it behind before Adam Wells could pounce.
Shortt, who scored the winner in extra-time away to Sligo Rovers in the first round, then forced Nathan Shepperd into a fine save on 24 minutes with the Welsh keeper only able to push his effort away before Lewis Macari hooked the ball to safety.
Keith Ward then had a free kick deflect wide before the Co Louth men made the breakthrough somewhat against the run of play on 38 minutes.
Runar Hauge beat Paul Cleary on the left to drill a low cross into the box which the home side failed to clear. That allowed Steven Bradley to get a shot away which was spilled by Moody.
McMillan then reacted quickest to slot in from a tight angle to set a new club record as Dundalk’s all-time leading goalscorer in the FAI Cup with 15 goals.
The visitors were fortunate though not to be pegged back straight from the kick-off as their defence was caught napping but fortunately for them Shepperd was quick off his line to slide tackle Shortt as he looked to be through on goal.
The Welsh keeper then came to his side’s rescue again in stoppage time at the end of the half when he made a brilliant point blank save to deny Harry Groome after he had been put in the clear by Crowley.
Shepperd was called on again 10 minutes after the restart to keep his side ahead when he denied Wells at close range.
There was nothing the 21-year-old could do a minute later on 56 minutes though as Lovic intercepted a short pass from Boyle towards Sloggett before bursting clear through to slot under Shepperd to make it 1-1.
Shepperd would then deny both Wells and Shortt within a minute of each other as Wexford went in search of the lead goal and it arrived on 66 minutes when Shortt got in behind Boyle on the left to fire to the bottom right hand corner.
Two minutes later Shortt broke through again and looked like he would make it 3-1 only for a heavy touch to allow Shepperd to smother.
That would prove decisive as O’Kane levelled matters on 73 minutes with a dazzling burst off the left before finishing left-footed to the bottom right hand corner.
Six minutes from the end Wexford missed a guilt-edged chance to restore their lead when Conor Davis broke to the end line on the left before crossing to Groome who blazed over when it looked easier to score.
Dundalk then passed up a big chance of their own on 87 minutes when Benson’s free kick found Robbie McCourt unmarked five yards out but his header was straight at Moody.
Groome had another half chance eight minutes into extra-time when he was picked out at the edge of the box by Thomas Considine but his effort was into the ground making it easy for Shepperd to save.
Benson then pulled a rare effort wide for the visitors on 103 minutes before volleying narrowly over from John Martin’s lay-off two minutes later.
Dundalk were then thrown a major lifeline on 110 minutes when Martin was felled in the box with Benson - scorer of the decisive penalty in last November’s Cup success for St Patrick’s Athletic - slotting past Moody to give the Lilywhites a lead which they held onto until the end.
Wexford FC: Alex Moody; Paul Cleary (Aaron Dobbs 74), Joe Manley, Jordan Tallon, Len O’Sullivan; Conor Crowley (Mitchell Byrne 102), Eoin Farrell, Luka Lovic, Harry Groome (Dinny Corcoran 109), Adam Wells (Conor Davis 74); Ger Shortt (Thomas Considine 87)
Dundalk: Nathan Shepperd; Lewis Macari, Sam Bone, Andy Boyle, Robbie McCourt (John Mountney 92); Greg Sloggett, Keith Ward (Robbie Benson 61); Steven Bradley, Joe Adams (Ryan O’Kane 61), Runar Hauge (Alfie Lewis 61); David McMillan (John Martin 83)
Referee: Adriano Reale (Kildare)