Stephen O'Donnell was the match winner on a night when Stephen Kenny recorded his first win as Dundalk manager.
Trailing 1-0 at half-time, they bounced back impressively. John Dillon levelled from the spot on 55 minutes, O'Donnell added the crucial 86th-minute lead goal and John Mountney sealed the points with a third four minutes into injury-time.
Shels Graham Gartland was dismissed for a second bookable offence in the 84th minute.
Kenny's cubs started brightly, passing the ball with brisk efficiency and created two chances, Kurtis Byrne's effort forcing Niall Burdon to make a good save.
They also had a goal disallowed – when Pat Hoban fouled Burdon – and then got hit with a sucker punch when, on 43 minutes, Dean Kelly connected with Mark Leech's cross to head Shels into the lead. They looked like extending it when Hughes' goal-bound effort was heading goalwards, but Peter Cherrie pulled off a great save.
Then, Ian Ryan fouled Keith Ward. Dundalk had a penalty and a reprieve. Dillon scored and the game changed – leading to O'Donnell and Mountney's late goals.
Shelbourne – Burdon; Ryan, Gartland, Cornwall, Shortall (McCabe 84); Hanlon, Brennan (Hurley 67), Bayly; Leech, Kelly (Mooney 82), Hughes
Dundalk – Cherrie; Rossiter, Osborne, Sullivan, Boyle; O'Donnell, Dillon (Mountney 76), Towell, Ward (Meenan 68); Hoban (Faherty 65), Byrne
Ref – A Buttimer (Cork)