Despite being outplayed for most of the second half, Dundalk, snatched an Airtricity League Premier Division win at Inchicore, while St Pat's have a lapse in concentration to blame for not getting at least a point.
John Dillion's penalty gave the visitors the lead just before the break.
But having just levelled the game at 1-1, thanks to Conan Byrne's well-taken goal on the hour mark, the Saints contrived to be authors of their own misfortune.
Ger O’Brien played a pass back to keeper Brendan Clarke, who was caught in possession by Kurtis Byrne, who could not miss from six yards.
Dundalk did have the better of the opening exchanges, with Vinny Faherty causing some problems for the Pat's defence
Both Keith Ward and John Sullivan had decent chances for Dundalk either side of Christy Fagan's 20th-minute attempt, which was the hosts' best chance of the half.
Fagan got on the end of a beautifully floated ball from Seán Gannon, but his touch took him left of the goal. His shot, when it came, fizzed harmlessly across the face of Peter Cherrie's goal.
The visitors took the lead from the penalty spot four minutes before the break courtesy of Dillon.
Kurtis Byrne was unlucky not to score when his shot was touched onto the crossbar and back into play by Clarke.
In challenging for the bouncing ball, Ger O'Brien fouled Keith Ward and referee Alan Kelly had no option but to point to the spot.
Dillon put the penalty low to the keeper's left and the Louth side took the lead.
St Pat's started the second half with great intent and 15 minutes of pressure paid off when they equalised thanks to Byrne, who had come on for Jake Kelly at half time.
The former Shelbourne winger scored low to the keeper's right after Gannon retrieved his own shot from the save and put it back across the box.
Parity did not last long though, and just two minutes later Clarke's calamity saw Stephen Kenny's side re-take the lead.
The Inchicore side again piled on the pressure and were unlucky not to be awarded a penalty themselves five minutes from time.
Conan Byrne's shot appeared to strike Andrew Boyle's hand inside the box, but the referee waved play on.
Dundalk held on through five minutes of injury time to claim victory.
St Patrick's Athletic: Brendan Clarke, Ger O'Brien, Kenny Browne, Conor Kenna, Ian Bermingham, Jake Carroll (Killian Brennan HT), Greg Bolger, Seán Gannon (Anto Flood 77), Jake Kelly (Conan Byrne HT), Christy Fagan, Christopher Forrester
Dundalk: Peter Cherrie, John O'Sullivan, Andrew Boyle, John Dillon (Darren Meenan 79), John Mountney (Chris Shields 50), Keith Ward (Stephen McDonnell 67), Dane Massey, Richard Towell, Mark Rossiter, Vinny Faherty, Kurtis Byrne
Referee: A. Kelly