Dundalk will go into Tuesday night's promotion/relegation play-off first leg tie with Waterford United in good spirits after Barry Conlon secured the Lilywhites a 2-1 win over Bray Wanderers at Oriel Park.
The home side went ahead after just 98 seconds when Gareth Brady's perfectly weighted pass set Lorcan Shannon clear on the right and his cross was knocked home by Michael Rafter.
Bray hit back in the 70th minute when Marty Waters beat Peter Cherrie with a stunning effort before substitute Conlon knocked it home in the 80th minute to give Dundalk their first league win since May.
Rafter's early goal set the tone for an entertaining half and Jason Byrne almost wiped out Dundalk's opener with a powerful shot that Cherrie had to turn over the bar in the sixth minute.
Cherrie was called into action again just before the break, beating a Dean Zambra effort away after Byrne had cushioned the ball down brilliantly for the strike.
Byrne was stretchered off with an injury after 55 minutes but Bray did pull level 15 minutes later when Waters beat Cherrie with a dipping effort from the left of the penalty area.
The goal came just 60 seconds after William Woods blazed over with a glorious opportunity to put Dundalk two ahead.
However the home side, knowing that a failure to win would equal a club record of 19 games without a league victory, were given a welcome lift when youngster Mark Leavy unselfishly squared the ball for fellow sub Conlon to finish from close range.
Dundalk: Peter Cherrie; Robbie Gaul, Paul Whelan, Liam Burns, Nathan Murphy; Lorcan Shannon (Mark Leavy 77), Mark O'Brien, Stephen McDonnell, Gareth Brady (Barry Conlon 70), Chris Reilly; Michael Rafter (William Woods 60)
Bray Wanderers: Darren Quigley; Daire Doyle, Shane O'Connor, Danny O'Connor, Kevin Knight (Yani Georgiev HT); Dean Zambra, Kevin O'Connor, Paul Moffatt (Colm Tresson 75), Sean Houston; Jason Byrne (Dane Massey 55), Kieran Waters
Referee: Derek Tomney.