Villarreal relegated on final day
Villarreal tumbled out of the Primera Division after losing to Atletico Madrid while relegation rivals Real Zaragoza and Rayo Vallecano won.
The Yellow Submarine, who finished fourth last season, saw a dismal season end in disappointment as Radamel Falcao's 88th-minute goal enabled Europa League winners Atletico to win 1-0 at El Madrigal.
Zaragoza started the day in the bottom three but were 2-0 winners at eight-man Getafe.
The real escape story came in Madrid, however, with Rayo leaving it until injury time to beat Granada courtesy of Raul Tamudo's dramatic effort.
Sporting Gijon will also play second tier football next season as their unlikely bid to avoid the drop ended in failure after a 1-0 defeat at Malaga, who secured fourth and a Champions League spot as a result.
Villarreal looked to have secured the point that would have preserved their top-flight status only for Falcao to continue his and Atletico's excellent week as he rose above the defence to power home Diego's corner despite Diego Lopez's best efforts.
Marco Ruben had one final chance to save his side, but his header from Nilmar's cross in stoppage time slipped just wide to the frustration of a disconsolate El Madrigal crowd.
For much of the evening, Rayo looked dead and buried but veteran substitute Tamudo had the final say, popping up to head home from close range after Medina Piti's shot had been blocked.
Zaragoza ensured they will play Primera Division football next season with a win in a game marred by four red cards.
The visitors were handed the initiative midway through the first half when Pablo Sarabia was stupidly sent-off for applauding referee Teixeira Vitienes' decision to book him and Getafe were reduced to nine men after the break when Miguel Torres was shown a second yellow card for handling inside the area.
Midfielder Apono coolly slotted away the resulting penalty but Zaragoza were reduced to 10 men when substitute Tomislav Dujmovic was shown a straight red card with seven minutes remaining.
However, after Miku became the fourth player to be given his marching orders, Helder Postiga sealed the points with a stunning strike into the top corner in stoppage time.
Malaga condemned Sporting to the drop as Jose Salomon Rondon scored the only goal.
Levante secured a Europa League spot thanks to a convincing 3-0 win over Athletic Bilbao.
Athletic, who also lost 3-0 to Atletico in the Europa League final in Bucharest on Wednesday night, were beaten by a brace from Algerian striker Abdelkader Ghezzal and a late Francisco Farinos penalty.
Racing Santander ended a miserable season with another defeat as Osasuna cruised to a 4-2 victory at El Sardinero.
The hosts were guaranteed to finish bottom of the table but failed to give their fans some much-needed pre-summer cheer as the Pamplona club hit back from an early deficit to win at a canter.
Christian Stuani handed Racing a second-minute lead but Ibrahima Balde, Alvaro Cejudo and Raul Garcia put Osasuna in charge.
Jairo Samperio pulled one back but Osasuna had the final word courtesy of Roversio. The win meant Osasuna ended the season in seventh but results elsewhere ensured their bid to qualify for the Europa League ended in disappointment.
Sevilla's faint hopes of nudging into a Europa League qualifying place also came to an end as they finished their season in ninth place after a 1-1 draw at Espanyol.
Sevilla needed to win and hope three other results went their way, but despite Alvaro Negredo's opener in first-half injury time they were pegged back by a 77th-minute strike from Philippe Coutinho.
At the summit, Real Madrid became the first team in the history of the Spanish league to reach 100 points for a top-flight season as they crushed Real Mallorca 4-1 at the Bernabeu.
Jose Mourinho's Primera Division champions signed off for the summer with a typically imposing performance as Cristiano Ronaldo and Karim Benzema set them on the way before half-time, with Mesut Ozil adding a second-half double.
Gonzalo Castro replied for Mallorca, who entered the game with the hope that victory could carry them into a Europa League place but found their opponents determined to end the season in style.