Madrid - Big-spending Malaga secured fourth place in La Liga and a first shot at the Champions League with a 1-0 home win over Sporting Gijon, who joined Villarreal in being relegated, in a dramatic finale to the season on Sunday.
The last eight matches of the season had three places in Europe and two relegation slots at stake as the games all kicked off at the same time with fans glued to their radios in grounds around Spain.
Salomon Rondon headed Malaga in front from a corner just after halftime, putting the Qatar-owned club on 58 points, ahead of Atletico Madrid and Levante who finished fifth and sixth to secure entry to the Europa League.
Atletico beat Villarreal 1-0 with an 88th-minute header from Radamel Falcao, the hero of their midweek Europa League final win over Athletic Bilbao, and condemned the team that finished fourth last season to relegation.
Villarreal were hanging by a thread in 17th when news filtered through that Rayo Vallecano had grabbed a 90th-minute winner through Raul Tamudo, for a 1-0 victory over Granada.
Rayo pushed Villarreal, the Champions League semi-finalists in 2006, down into the second division and a pitch invasion at their tiny stadium saw players being stripped of their kit.
“It's very tough,” Villarreal defender Angel told Spanish television as he left the pitch at the Madrigal.
“Football is like this. Sometimes strange things happen. We have to try and pick ourselves up. This is football.”
Real Zaragoza escaped from the bottom three with a 2-0 victory at Getafe who finished with eight men on the pitch.
Levante secured their highest league finish in their 102 years with a 3-0 rout of losing Europa League finalists Athletic Bilbao, and qualified for European competition for the first time.
Abdelkader Ghezzal scored twice and Francisco Farinos grabbed a late penalty to cap a remarkable campaign.
Champions Real Madrid signed off with a 4-1 hammering of Real Mallorca at the Bernabeu to set a new La Liga record of 100 points for a season, beating the previous best of 99 achieved by Pep Guardiola's Barcelona in 2010.
Cristiano Ronaldo, with his 46th league goal of the campaign, Karim Benzema and a double from Mesut Ozil lifted Real to a league scoring record 121 goals.
Real ended nine points ahead of deposed champions Barcelona, who signed off with a 2-2 draw at Real Betis on Saturday.
Valencia were 30 points back in third in the last automatic qualification Champions League slot despite losing 1-0 at Real Sociedad on Saturday. - Reuters