Mayo have joined Tyrone, Dublin and Kildare in the Allianz Football League Division 1 semi-finals.
The Connacht champions edged out Cork by 0-11 to 0-10 at Pairc Ui Chaoimh to leapfrog the Rebels.
Kerry avoided relegation thanks to a 1-16 to 2-12 win over Tyrone in Omagh.
That result meant All Ireland champions Donegal go down after a draw with Dublin.
Down will also play in Division 2 next season despite a 3-13 to 1-12 win over Kildare.
Dublin will play Mayo in the semi final while Kildare will face Tyrone.
Derry secured promotion to the top flight with a 2-17 to 1-5 win over Westmeath. The two sides will meet again in the Division 2 final.
Louth beat Longford by 1-14 to 1-8 which means Longford are relegated along with Wexford who lost to Laois by 0-14 to 1-8.
Armagh beat Galway by 0-21 to 1-12.
Monaghan and Meath were promoted from Division 3 while Wicklow and Antrim do down.
Limerick and Offaly go up from Division 4.
©INPHO/Donall Farmer