The champions had uncharacteristically dropped four points in consecutive draws with Bray Wanderers and Derry City and O’Connor’s injury-time strike was the least the students deserved after an excellent second-half display.
After Gary McCabe had threatened down the right wing for Rovers as early as the second minute, the league’s top scorers opened theiraccount three minutes later, availing of a dubious free-kick awarded against David O’Connor for an alleged foul on Gary Twigg.
Billy Dennehy took aim from 22 yards out and curled a powerful low shot around the wall and beyond the dive of Mark McGinley.
That the hosts continued to dominate territory and possession as the half progressed spoke volumes for UCD’s limitations. A Daniel Ledwith speculative shot was their first attacking foray in the 27th minute.
In the 40th minute, Twigg turned adroitly from Conor Powell’s throw-in before applying a sumptuous chip over the stranded McGinley from 25 yards to double the champions’ advantage.
Rovers’ frailties were exposed in the 59th minute, however, as Conor McCormack needlessly felled Ledwith inside the penalty box and Graham Rusk calmly sent keeper Oscar Jansson the wrong way from the spot. The Students suddenly had something to build on.
Twigg had a number of opportunities as the half progressed but the Scotsman lacked his usual guile in front of goal.
But the Hoops were made to pay for not closing the game out as O’Connor ran onto Hugh Douglas’s through ball to slot home from 12 yards.
SHAMROCK ROVERS: Jansson; McCormack (Gilbert, 81), Sives, Gartland, Powell; McCabe, Rice, Turner, Dennehy (Greene, 73); Kavanagh (Brennan, 62), Twigg.
UCD: McGinley; Douglas, D O’Connor, Leahy, Ledwith; Rusk, Corry, P O’Connor, Benson (Belhout, 46), Langtry; Lyons (Morrison, 84).
Referee: D McKeon (Dublin).