Despite finishing with nine men, Aaron O'Driscoll’s header brought Longford Town their first league win in 26 matches since the opening night of the season to heap further misery on freefalling Dundalk following this clash of the bottom two at Bishopsgate.
While Longford are 14 points adrift at the bottom of the table despite the 1-0 triumph, Dundalk's fifth defeat in seven games means they remain in the relegation play-off place, a point behind Waterford.
And though Vinny Perth's side, who also had substitute Han Jeong Woo sent off in stoppage time, have two games in hand, they are against Sligo Rovers, at the Showgrounds on Tuesday, and at home to Bohemians.
With three changes from last week's scoreless draw in Waterford, Dundalk started brightly with Pat Hoban heading over a Will Patching free kick on three minutes.
Scarcely a minute later they should have been ahead. Raivis Jurkovskis was given far too much time and space on the right to whip over a cross to the back.
But Sam Stanton somehow contrived to volley over the top when it looked easier to score.
The hard-working Hoban soon carved Town open again. Joe Manley, O'Driscoll and Dean Zambra were left in his wake only for Hoban to scuff his shot which was comfortably gathered by Lee Steacy.
Town were then relieved on the double to see a linesman’s flag raised as Hoban headed just off target from Cameron Dummigan’s cross as they were once more all too easily opened up.
It was 18 minutes before a mistake at the other end brought Longford their first sight of goal.
Sonni Nattestad’s short pass never reached Dummigan allowing Darragh Nugent to nip in and drill his shot just wide of Cameron Yates’ right-hand post.
But Dundalk continued to stretch the Town whenever they got forward. And superb defending was needed to keep the visitors out on the half hour.
Patching’s quick free kick found the run of Greg Sloggett whose shot was blocked by the retreating Nugent.
Dundalk skipper Andy Boyle had to do likewise from Town’s Aaron Robinson as Town promptly responded.
Steacy then kept Dundalk out with the save of the half on 40 minutes before a goalkeeping howler at the other end brought Town the lead.
Having scampered to the end line, Dundalk midfielder Stanton’s cross wasn’t cleared.
Hoban did really well to control the ball and turn to get his close range shot away which Steacy brilliantly smothered.
It proved pivotal as Longford landed a sucker punch right on 45 minutes.
Though O’Driscoll got a firm header to Dylan Grimes’ superbly flighted free kick, Yates, on his league debut, allowed the ball to squirm under him and cross the line.
It was backs to the wall stuff from Longford throughout the second half as they were reduced to 10 men on 58 minutes.
Booked seven minutes earlier, midfielder Robinson received his second booking for a foul on Will Patching.
From Patching’s resulting free kick, Boyle was inches from equalising as he saw his shot come back off a post.
Longford lost striker Rob Manley when harshly shown a straight red card for tripping Ryan O’Kane on 84 minutes.
Dundalk's Han was then also sent off for a foul on Joe Manley in the 92nd minute before Steacy produced the save of the game to tip over a Stanton header as Longford held out.
Longford Town: Lee Steacy; Shane Elworthy, Aaron O’Driscoll, Joe Manley, Dean Zambra (Aodh Dervin 63); Rob Manley, Aaron Robinson, Darragh Nugent, Dean Byrne (Aaron McNally 57); Dylan Grimes (Aaron Dobbs 77); Dean Williams (Callum Warfield 77).
Dundalk: Cameron Yates; Dan Cleary, Andy Boyle, Sonni Nattestad (Mark Hanratty h-t); Raivis Jurkovskis, Sam Stanton, Will Patching, Greg Sloggett (Han Jeong Woo, 83), Cameron Dummigan (Michael Duffy 63); Sami Ben Amar (Ryan O’Kane 69); Pat Hoban.
Referee: Derek Tomney (Dublin).