Shamrock Rovers 3 Longford Town 2
Trevor Molloy hit a last minute penalty to rubber stamp Rovers' InterToto Cup place.
Rovers appeared to be cruising with goals from Stephen Grant, just before half-time, and Shane Robinson on 58 minutes putting them in control.
But Town staged a late recovery with two goals inside a minute late on from Eric Lavine and 17-year-old debutant Adrian Murphy.
In a final twist, though, Town captian Vinny Perth handled on the line, for which he was sent off, to present Molloy with the winning penalty.