Deportivo La Coruna suffered relegation on an enthralling final day of the season, as Cristiano Ronaldo wrote his name into the Primera Liga record books.
Ronaldo set a new mark for goals scored in a Spanish league season when he netted his 39th and 40th of the campaign in Real Madrid's astonishing 8-1 victory over Almeria, surpassing the previous best of 38 that was jointly held by former Real striker Hugo Sanchez and ex-Athletic Bilbao frontman Telmo Zarra.
The Portuguese forward only needed four minutes to grab the record-breaking goal, bundling in at the far post from a Sergio Ramos header to set Real on their way to a remarkable rout.
He also bagged the seventh in the 77th minute, running from deep and firing a long-range effort inside the far post.
Emmanuel Adebayor, whose loan spell from Manchester City is expiring, signed off with a hat-trick, Karim Benzema bagged two and youth-team player Joselu notched one at the end to take Real's tally for the season to 102 goals.
Kalu Uche's strike was all that Almeria had to celebrate as the league's bottom side bowed out with a whimper.
Pep Guardiola had one eye firmly on next weekend's UEFA Champions League final against Manchester United as newly-crowned Spanish champions Barcelona did without the majority of their first team at Malaga but still came away with a 3-1 victory to end the campaign four points clear of Real Madrid.
Mid-table Malaga did provide Barca with an early scare when Sebastian Fernandez was given time and space to open the scoring, but Bojan Krkic levelled things up from the penalty spot.
A long-range shot from Ibrahim Afellay and a header from youth-team player Marc Bartra in the last 15 minutes then sealed Barca's 30th win of the season.
Already-relegated Hercules played out a goalless draw with Sporting Gijon in another early kick-off.
The real drama was to come in the evening, though, as six teams entered their final game of the season still embroiled in the scrap for survival.
Real Zaragoza occupied the final relegation place ahead of kick-off but avoided the drop thanks to a 2-1 victory over Levante, with Gabi scoring twice.
Deportivo subsequently bowed out of the top flight, despite amassing 43 points over the course of the season, after going down 2-0 at home to Valencia.
Aritz Aduriz struck for Valencia after just four minutes and fallen giants Depor agonisingly toiled in vain for the rest of the match, before Roberto Soldado's breakaway goal in stoppage time sealed their demise.
Real Sociedead met Getafe in a match between two sides very much in danger but, with Depor losing, there was less urgency to win and the outcome was a 1-1 draw, with both staying up.
Cata Diaz's early opener for Getafe was cancelled out by Francisco Sutil midway through the second half.
Osasuna also retained their Primera Liga status for next season after Alvaro Cejudo's goal secured a 1-0 success over fourth-placed Villarreal.
Real Mallorca supporters endured a rollercoaster night as they slipped to a thrilling 4-3 defeat at home to Atletico Madrid but, crucially, remained in the division.
Atletico stormed into a 3-0 lead thanks to a Sergio Aguero double and Juanfran strike, but Mallorca hit back through Jonathan de Guzman and Pierre Webo.
Aguero completed his hat-trick to make it 4-2 and Atletico held on despite Webo netting his second of the night.
Away from the relegation battle, Europa League qualifiers Sevilla ended their campaign in style with a 3-2 victory over Espanyol.
Alvaro Negredo scored twice and Frederic Kanoute once for Sevilla, while Pablo Osvaldo and Joan Verdu found the target for Espanyol.
Goals from David Lopez and Fernando Llorente helped Athletic Bilbao win 2-1 away to Racing Santander.