A stoppage time strike from Paul Marney handed Dundalk a 3-2 win over UCD at Oriel Park.
The Louth club have made a disastrous start to the season and lie bottom of the First Division with no points from the opening three games.
The League Cup was a welcome distraction for the Lilywhites and for long periods of this game they looked like they would run out comfortable winners.
After dominating the first-half, Dundalk eventually took the lead a minute before the interval when Niall Hudson raced onto David Hoey’s through-ball to rifle past Mark Clohessey.
UCD’s Paul Byrne levelled matters 13 minutes from time with a stunning strike from 30 yards.
The Students then looked like they would steal the win when they caught the home side on the break on 85 minutes with Conor Sammon turning home Conan Byrne’s cross.
Dundalk managed to level on the stroke of full-time, however, as Philip Hughes volleyed spectacularly to the net from Andrew Duffy’s cross.
Marney then completed a memorable comeback when he slotted home a Peter Hynes cross late on.