UCD sent high-flying Derry City reeling as they secured a smash-and-grab victory at the Brandywell.
All six goals came in an action-packed second half in which two penalties were awarded and the home side had defender Dermot McCafffrey sent off.
UCD were inches away from taking the lead on 16 minutes when David McMillan's cross flashed just in front of Robert Benson and into 'keeper Gerard Doherty's arms.
The hosts then had two super chances when Mark Griffin's snap-shot was kept out by Conor O'Donnell and right-back Simon Madden's follow-up hit an upright.
Martin Russell's side broke the deadlock on 60 minutes following a slick move which ended with Benson side-footing the ball home.
Derry equalised six minutes later in fantastic fashion. Griffin did well to get away from two challenges and passed the ball to Rory Patterson, whose first-time shot from 25 yards flew past O'Donnell.
Barry McNamee's curled free-kick put the hosts ahead, and they were denied a third when Sean Houston's header rattled the crossbar, before two penalties dramatically changed the match.
The first came on 80 minutes when Dean Clarke was brought down by McCaffrey, who was shown a straight red before McMillan fired home the spot-kick.
UCD were awarded a second penalty on 84 minutes when Griffin was adjudged to have brought down Sean Russell inside the box. McMillan again made no mistake from the spot, smashing the ball high into the net.
The visitors struck again in stoppage-time when Clarke drilled the ball into Doherty's bottom corner from long range.
Derry City – Doherty, Madden, Greacen (Duffy 87); McBride, McCaffrey; Molloy, Houston, B McNamee; Griffin, Patterson, Rafter (McEleney 67).
UCD – O'Donnell, Douglas, Kavanagh, O'Connor, Russell; Morrison (Crowe 73); McCabe (Burke 81); Walsh (O'Halloran 73); Clarke; Benson; McMillan.
Ref – P McLaughlin (Monaghan).