City looked to be heading home empty-handed when Gary Twigg opened the scoring for the Hoops two minutes earlier but another defensive lapse from the title holders saw them fail to take advantage of Sligo’s dropped points against Bohemians.
The visitors arrived in rude health after encouraging results in both league and cup competitions as they looked to improve on their 1-1 draw against the title holders earlier in the campaign.
In a tense opening, Rovers’ Daryl Kavanagh registered the first shot in anger in the 7th minute which dribbled well wide while at the opposite end Tadhg Purcell was marginally closer with a curled effort that flew wide of Oscar Jansson’s left hand upright six minutes later.
The Hoops gradually began to assert themselves and they could have taken the lead in the 16th minute as a mazy run and excellent cross by Gary McCabe found the head of Twigg, who nodded wide from six yards with Mark McNulty rooted to his line.
A 21st-minute Vinny Sullivan snapshot aside, there was little attacking intent from City as their defensive mindset was reflected in bookings for both Kalen Spillane and McNulty as the half progressed.
Twigg and Colin Healy joined them in the as the half progressed, with City indebted to a wonderfully timed challenge by Gavin Kavanagh on Twigg after an incisive through ball from Daryl Kavanagh on the half hour.
With Rovers pressing hard, they left gaps at the back and they were almost exposed in injury-time when, after a fine move involving Colin Healy and Purcell, Vinny Sullivan was denied by a brave block by Oscar Jansson.
The second-half saw the hosts resume in determined fashion and after Craig Sives had clipped the crossbar with a header from Billy Dennehy’s corner, Twigg blazed over from another Dennehy centre.
In the 50th minute, Finn timed his run to perfection to meet Twigg’s knock-down but from 12 yards his powerful volley cannoned off the crossbar and away for a corner.
With City on the ropes, Graham Gartland failed to land a decisive blow from the ensuing set-piece as he wastefully headed over from six yards as McCabe once again delivered with unerring accuracy.
On the hour mark, City appealed in vain for a penalty kick although they appeared to have genuine grounds as Dennehy made contact with Purcell inside the area following a fumble from Jansson.
Eventually, Twigg found his range five minutes later when substitute Aaron Greene curled a sublime cross from the left-hand touchline and the Scotsman made no mistake with an unerring header from eight yards beyond McNulty for his 13th goal of the campaign.
However, City found space behind Conor Powell in the 87th minute and from Purcell’s sumptuous cross, Dunleavy joined the attack to telling effect with an arrowed header into the top corner of Jansson's goal.
SHAMROCK ROVERS: Jansson; Gilbert, Sives (Hawkins, 61), Gartland, Powell; McCabe, McCormack, Finn, Dennehy; Kavanagh (Greene, 74), Twigg.
CORK CITY: McNulty; Healy, Kavanagh, Spillane, Dunleavy; Horgan (Turner, 90), Morrissey, Duggan, O'Neill; Sullivan (Kenny, 90), Purcell.
Referee: Rob Rogers (Dublin)