Villarreal's 12-year stay in the top flight came to a shock end as Radamel Falcao's late goal for Atletico Madrid earned a 1-0 win and sent the Yellow Submarine down to the Segunda Division.
Villarreal, who finished fourth last season, seemed set to survive as they withstood a second-half onslaught from the Europa League winners.
However, Falcao's 88th-minute header from Diego's corner, allied to victories elsewhere for Rayo Vallecano and Real Zaragoza, meant it was Miguel Angel Lotina's side who join Sporting Gijon and Racing Santander in the bottom three.
Jose Salomon Rondon's second-half header was enough to earn Malaga a 1-0 win and Champions League football for the first time in their history and ensure that Sporting Gijon were relegated.
The hosts dominated from start to finish and only a combination of some fantastic goalkeeping from Juan Pablo, poor finishing and the woodwork managed to keep the score down.
Raul Tamudo netted a stoppage-time winner as Rayo Vallecano escaped relegation in the most dramatic of circumstances as they beat Granada 1-0.
Rayo, who had lost nine of their previous 10 games coming into this match, looked certain to be making an immediate return to the Segunda Division as they found themselves in the bottom three heading into the final minutes.
However, veteran striker Tamudo, having come off the bench, popped up in the first minute of injury time to head home from close range and give Rayo a stunning victory that keeps them in the top flight. Granada were also at risk of relegation but they escape the drop with Villarreal the surprise casualties.
Real Zaragoza ensured they will play top-flight football next season after a 2-0 win over Getafe 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 resultant 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.
Two goals from Algerian striker Abdelkader Ghezzal paved the way for Levante to hold onto sixth place and with it qualification for next season's Europa League following a 3-0 win over Athletic Bilbao.
Juan Ignacio's men headed into the game against Athletic Bilbao knowing anything other than a win was unlikely to be enough and they coasted home with Ghezzal's brace and a late Francisco Farinos penalty giving them a comfortable win.
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 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.
Sevilla's faint hopes of nudging into a Europa League qualifying place came to an end as they finished 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.
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 Balde Ibra, 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.