Cork retained their Division 2 status by the skin of their teeth after an enthralling relegation shootout with Offaly in Tullamore.
Behind by 1-19 to 1-17 with five minutes of normal time remaining, Cork were staring a devastating defeat in the face but they rallied powerfully to pull the game out of the fire.
After Brian Hurley and Ruari McNamee swopped points, Cork were still behind by a point as it drifted into injury time.
However, they got the win with points from Cian Kiely and a Stephen Sherlock free, awarded controversially for a kickout infringement after Paddy Dunican took a short one and then stopped the ball from going out over the end line.
Offaly manager John Maughan did not take issue with that free afterwards, stating that he was not fully aware of the technicalities of the rule and instead focussing on a very brave display by his side while insisting that they would get fully up for the Tailteann Cup if they do end up there later in the year.
It was a frantic end to a quite superb game of football, played on a summer type day in a championship-type fervour with two passionate sets of supporters creating a superb atmosphere.
It was fitting that Sherlock got that late free as he was ultimately the difference between the teams, kicking nine points with five of them from play.
Cork started superbly and could have been out of sight after ten minutes as they tore into Offaly.
An excellent second-minute goal from Cathal O'Mahony helped them to a 1-04 to 0-01 lead after 11 minutes but it could have been much more. Twice Colm O'Callaghan took points with the goal at his mercy – he fisted over after 16 seconds when he really should have went for it while his tenth-minute point was not as clear cut, it was still a chance.
Offaly settled down after this and got some points out of the top drawer to get back into it. Niall McNamee's two were particularly breathtaking and Offaly had it back to 1-06 to 0-05 after 20 minutes.
Cork responded well and three points from Stephen Sherlock put them six ahead. Offaly got right back into it with an Anton Sullivan goal from a penalty with Kevin Flahive black-carded for hauling Niall McNamee down.
Bill Carroll and Sherlock exchanged points to leave Cork ahead by 1-10 to 1-07 at the break.
Cork got the first three points of the second half to go 1-13 to 1-07 ahead and with the wind on their backs, it was difficult to see a path back for Offaly.
Even when the home side rallied with four on the trot, Cork got the next two through John O'Rourke and Hurley to lead by 1-15 to 1-11 after 47 minutes.
They were still very much in the driving seat but Offaly read from a different script and through caution to the wind. They played very brave attacking football, taking chances and kicking some quality scores.
Offaly got three to bring it back to a point, Cork edged two clear again and were a point up, 1-17 to 1-16 with 57 minutes gone.
Offaly ripped into them after this. Paddy Dunican (free) Anton Sullivan and Niall McNamee (mark) pointed to put Offaly 1-19 to 1-17 and a shell-shocked Cork didn't know what hit them.
They regained their composure, however, and it was a very relieved Cork team who walked off the field at the final whistle.
Offaly: Paddy Dunican (0-01f); Kieran Dolan, James Lalor, Niall Darby (0-01); Lee Pearson, Declan Hogan, Colm Doyle; Cathal Donoghue, Jordan Hayes; Dylan Hyland, Ruari McNamee (0-02), Bill Carroll (0-03); Johnny Moloney (0-01), Niall McNamee (0-07, 2f, 2m), Anton Sullivan (1-03, 1-00pen).
Subs: Cathal Flynn (0-01) for Pearson (23), Keith O'Neill (0-01) for Donoghue (40), Mark Abbott for Hyland (50), Ciaran Donnelly for Doyle (55), Bernard Allen for Sullivan (68).
Cork: Micheal Martin; Kevin O'Donovan, Kevin Flahive, Tommy Walsh; Rory Maguire, John Cooper, Mattie Taylor (0-01); Ian Maguire, Cathal O'Mahony (1-01); Daniel Dineen, Eoghan McSweeney, Colm O'Callaghan (0-02); Stephen Sherlock (0-09), John O'Rourke (0-03), Brian Hurley (0-03).
Subs: Blake Murphy (0-10) for McSweeney (47), Cian Kiely (0-1) for Flahive (52), Mark Cronin for O'Mahony (53), Brian Hartnett for Dinneen (5), Fionn Herhily for O'Rourke (69).
Referee: Niall Cullen (Fermanagh).