A stunning header from John Martin with his first touch five minutes from time saw Dundalk claim the spoils against Shelbourne in a game in which both sides finished with 10 men.
Shane Griffin and Steven Bradley were sent-off in either half with Shels boss Damien Duff also dismissed in first-half stoppage time in a game that exploded into life at the end of drab opening 45 minutes.
When Bradley was sent-off on 57 minutes the game had had more reds than shots on target.
Shane Farrell looked like he had earned the visitors a share of the spoils when he scored from a debatable spot-kick nine minutes from the end to cancel out Daniel Kelly's opener but up popped Martin with his first Dundalk goal to ensure the Lilywhites inflicted a first away defeat of the season on Shels.
Dundalk moved up to fourth in the table while Shelbourne remain eighth.
📹 | GOAL!— SSE Airtricity League (@SSEAirtricityLg) April 22, 2022
John Martin's first goal for @DundalkFC restores their lead after it was put on a 🍽️ by Keith Ward!@shelsfc had equalised through a Shane Farrell penalty just minutes beforehand
Watch live | https://t.co/zOGOgOjp1S 📺#LOI | #LOITV pic.twitter.com/Iho3KIGfXM
Chances were at a premium in the first half. Paul Doyle had an early effort charged down by Mark Coyle before Bradley pulled a free kick to the left and wide on 14 minutes.
The young Scot then conjured up the only effort that required a save in the half on 27 minutes when his snap shot from the edge of the box forced Brendan Clarke to dive low to his left to make the save.
Shels' best chance of breaking the deadlock came on 42 minutes when Jack Moylan looked like he had broken in on the left but Darragh Leahy got across to make a superb block.
The major action would take place in stoppage time when Griffin, having earlier been booked for a foul on the same player, was shown a second yellow and then red for a tripping Bradley as he looked to break into the box.
His dismissal sparked a furious reaction from Duff, who was initially booked by referee Paul McLaughlin before being sent-off as well for his follow-up reaction.
Hoban fired the free kick wide after the two dismissals but went closer three minutes after the restart when he rose above Aaron O’Driscoll to head Lewis Macari’s cross against the frame of the goal.
Dundalk then had a real let-off on 52 minutes when Shane Farrell’s free kick picked out substitute Kameron Ledwidge unmarked at the back post but he couldn’t direct his effort on target.
Moylan kept the ball from going dead and cut into the box at the endline where he looked to be upended by Kelly but, much to the annoyance of the large travelling support, McLaughlin opted not to point to the spot.
The ref evened up the numbers on the field of play in the 57th minute when Bradley shown a straight red card for kicking out at Farrell after he had been fouled - the incident brought to the referee’s attention by his assistant Emmet Dynan.
The home side found the breakthrough on 64 minutes when great play by Hoban saw him keep the ball alive with a pass over his shoulder to Leahy. The full-back then teed up Doyle for a cross which found its way to Kelly at the back post and he tapped in the 30th goal of his career.
Kelly then went from hero to villain on 81 minutes when he was harshly adjudged to have fouled John Ross Wilson in the box, Farrell sending Shepperd the wrong way to level matters.
It was only 1-1 for around four minutes however as Martin got on the end of a stunning cross from the right by Keith Ward to head past Clarke and ensure a hard-fought win for his side.
Dundalk: Nathan Shepperd; Lewis Macari (John Martin 84), Mark Connolly, Andy Boyle, Darragh Leahy; Greg Sloggett, Paul Doyle (Sam Bone 74); Steven Bradley, Joe Adams, Daniel Kelly; Patrick Hoban (David McMillan 84).
Shelbourne: Brendan Clarke; JR Wilson, Aaron O’Driscoll, Luke Byrne, Shane Griffin, Conor Kane (Sean Boyd 70); Aodh Dervin (Jordan McEneff 78), Mark Coyle, Shane Farrell; Daniel Carr (Kameron Ledwidge HT), Jack Moylan.
Referee: Paul McLaughlin (Monaghan)