Former UCD striker Andy Myler scored twice - with the winner four minutes into stoppage time - to give First Division Athlone Town the advantage going into Friday's second leg of the Premier Division's promotion/relegation play-off.
Athlone went ahead from Myler's 14thminute penalty after Stuart Connolly was pulled down by Tony McDonnell. McDonnell made amends six minutes later when he got a second bite at Alan Mahon's free-kick to volley home from close range.
UCD were the better side for most of the match, but late in the second half Clive Delaney was dismissed after fouling a goal-bound Stuart Connolly.
Connolly then provided the corner deep into injury time from which Myler headed home his 29th goal of the season after UCD failed to clear.
ATHLONE TOWN: Connaughton; Fitzell, McCormack, C Frawley, O'Brien; Kelly, Costello, Connolly; Mullan, Myler, McNevin. Subs: Carberry and Harte for Mullan and McNevin (both 80 mins.).
UCD: Ryan; Mahon, McAuley, Delaney, O'Donnell; Martyn, McDonnell, Kavanagh, O'Mara; Bennis, Swan. Subs: J. Martin for Swan (62 mins.), R. Martin for Bennis (69 mins.), McLoughlin for O'Mara (85 mins.).
Referee: J O'Neill (Waterford).