Dublin 2-14 Cork 2-10
A nine-point haul from Cormac Costello proved decisive at Croke Park where holders Dublin showed remarkable resilience to steal a come from behind win and keep their Allianz Football League four-in-a-row title bid alive.
The All-Ireland champions looked in real trouble in the first-half when they trailed by eight points at one stage and hit the interval seven points behind a Cork side that leaked 4-25 to Roscommon in Round 3.
But the resurgent Rebels couldn't keep it going and were ultimately suckered by a terrific second-half performance from Dublin who outscored the visitors by 1-11 to 0-3 in that period.
Costello was central to most of Dublin's positive play, shooting all of his nine points in the second-half and booting eight of them from placed balls. He deserved to be the match winner and looked as if he would be when he put Dublin one ahead with his final score in the 70th minute.
But James McCarthy added a 74th minute goal to add some gloss to the scoreline.
The win, which puts Dublin on the brink of the semi-finals with three games left to play, was all the more impressive as they lost defender Jonny Cooper to a 63rd minute dismissal after his second booking.
Gavin made six changes to his side beforehand from the team that overcome Monaghan and, initially, they struggled against a Cork team eager to atone for the Roscommon setback and a previous loss to Donegal.
Colm O'Neill, a late inclusion for the Munster side, hit 1-03 including a converted 19th minute penalty to help Peadar Healy's team into a 1-04 to 0-00 score lead.
Diarmuid Connolly was named Man of the Match and dragged Dublin back with his 1-01.
Peter Kelleher's 29th minute goal kept Cork well in control though and they led by eight points at one stage before taking a deserved 2-07 to 1-03 lead into the half-time break.
They didn't score again until the 63rd minute though as Dublin took over and kicked nine points without reply.
Costello was excellent in open play and unerring from frees as he continually punished Cork's slack defending.
Dublin: M Savage; J Cooper, P McMahon, David Byrne; J McCarthy (1-00), C O'Sullivan, E Lowndes; B Fenton, E O Conghaile; P Flynn, D Connolly (1-03, 1-00pen, 0-02f), C Kilkenny; C Costello (0-09, 0-08f), P Andrews (0-02), B Brogan.
Subs: J Small for Lowndes, M Fitzsimons for Fenton, S Carthy (Naomh Mearnog) for O'Conghaile, D Rock for Brogan, K McManamon for Andrews, S Carthy (St Vincent's) for Flynn.
Cork: MA Martin; J O'Sullivan, E Cadogan, K Crowley; T Clancy, B O'Driscoll, K O'Driscoll; S Kiely, I Maguire; M Collins (0-01), L Connolly (0-01, 0-01f), C O'Driscoll (0-01); C O'Neill (1-03, 1-00pen, 0-02f), P Kelleher (1-00), P Kerrigan (0-01).
Subs: B Hurley for Kerrigan blood, D Goulding for O'Neill, K O'Hanlon for Kiely, Hurley (0-02, 0-01f) for K O'Driscoll 54, R Deane (0-01) for Connolly, A O'Sullivan for Kelleher, M Collins (O'Donovan Rosssa) for Kerrigan.
Referee: P Neilan (Roscommon)