Deportivo La Coruna produced an unlikely fightback at La Liga champions Barcelona to rescue a 2-2 draw, the point proving enough to stave off relegation along with Granada as Eibar and Almeria were consigned to the drop.
The latter two clubs began the day occupying 18th and 19th places respectively, and relegation was particularly hard on Eibar, who defeated bottom side Cordoba 3-0.
Almeria twice led at home to Valencia but eventually succumbed to a 3-2 defeat that confirmed their slip into the second tier and simultaneously ensured the visitors secured fourth place and UEFA Champions League qualification.
For much of the day, it seemed as though Deportivo would be one of the sides to go down as a brace from Lionel Messi had Barca 2-0 up after an hour on Xavi’s final Camp Nou appearance.
However, Lucas Perez pulled one back in the 67th minute, before Diogo Salomao equalised with 14 minutes to go as the visitors upset the odds and avoided dropping straight back into the Segunda Division.
That draw meant Depor stayed up alongside Granada, who played out a drab 0-0 draw at home with Atletico Madrid.
Both Depor and Granada finished on 35 points, level with Eibar who were relegated due to their inferior head-to-head record.
Goals from Mikel Arruabarrena, Raul Navas and Ander Capa gave Eibar their win over Cordoba, but ultimately it proved in vain for the minnows.
Almeria, meanwhile, finished three points worse off as Paco Alcacer’s 80th-minute winner saw Valencia take the three points they needed to secure fourth ahead of Sevilla, who overcame Malaga 3-2.
Copa del Rey finalists Athletic Bilbao ensured UEFA Europa League qualification with a 4-0 hammering of Villarreal, who are already assured of a place in that competition.
Aritz Aduriz scored twice, sandwiching efforts from Andoni Iraola and Benat Etxebarria as Athletic warmed up for next weekend’s Copa date with Barca in style
Elsewhere, Celta Vigo defeated Espanyol 3-2, Real Sociedad triumphed 4-2 at Rayo Vallecano and the clash between Levante and Elche ended goalless.