* Deportivo relegated with 2-0 defeat to Valencia
* Real hammer Almeria 8-1 and Barca come back to win 3-1
Deportivo Coruna were relegated from La Liga on the final day of the season on Saturday, a 2-0 defeat at home to Valencia ending a 20-year stay in the Spanish top flight.
Valencia's Aritz Aduriz scored after four minutes at the Riazor and after some desperate final minutes with the entire Depor team in the visitors' area, Roberto Soldado sealed their fate in the sixth minute of time added on.
Deportivo, league champions in 2000, finished 18th with 43 points, one from safety, and joined Almeria and Hercules in the second division next term.
"Next year we will return to the Primera division because we are going to do things well from the start of the season," Depor's veteran playmaker Juan Carlos Valeron told Spanish television as team mates lay on the pitch around him in tears.
"We'll take the team back to where they deserve to be."
Real Zaragoza had started the day in 18th place but won 2-1 at already-safe Levante, captain Gabi scoring both goals for Javier Aguirre's side.
Earlier, Cristiano Ronaldo set a new La Liga scoring record of 40 goals in a season and Emmanuel Adebayor grabbed a hat-trick as Real Madrid destroyed Almeria 8-1 at the Bernabeu.
Newly-crowned champions Barcelona also wrapped up their campaign with a victory, coming back to win 3-1 in Malaga with most of their first team being rested ahead of next weekend's Champions League final against Manchester United.
Barca, who secured their third consecutive league crown last week, finished with 96 points from 38 games, four ahead of second-placed Real Madrid, scorers of 102 league goals this term.
Sevilla and Athletic Bilbao both won to secure fifth and sixth places and automatic qualification to the Europa League while Atletico Madrid finished seventh and will play the qualification phase.
Six teams separated by only two points were fighting to avoid the last remaining relegation place when all their matches kicked off at 2000 GMT.
Reports said there were over 200 possible combinations of results, made complicated by the head-to-head records between sides deciding placings if they ended up level on points.
Deportivo slipped straight into the bottom three when Aduriz scuffed in a weak shot at the Riazor while Getafe, Zaragoza and Osasuna all went ahead in their respective games.
Real Mallorca trailed Atletico from the 12th minute, and went on to lose 4-3, meaning Depor only needed an equaliser to put the islanders into the bottom three but Valencia keeper Cesar Sanchez was in inspired form.
In the dying minutes, with Depor keeper Daniel Aranzubia going up to join the attacks, Cesar denied Lassad then Xisco and in a massive goalmouth scramble in the 90th minute, Alberto Lopo blazed wide of the post before Soldado scored on a breakaway.
It only took Real Madrid's Ronaldo four minutes to pass the previous league record of 38 goals, held by Hugo Sanchez and Telmo Zarra, when he slid in at the far post to score from a Sergio Ramos header.
He bagged the seventh in the 77th minute, while Adebayor, whose loan spell from Manchester City is expiring, signed off with three goals, Karim Benzema bagged two and youth team player Joselu notched one at the end.
Malaga struck first at the Rosaleda through Sebastian Fernandez but Barca levelled with a disputed penalty just before the break, Bojan Krkic netting from the spot.
The hosts had caused Barca plenty of problems in the first half but a long-range shot from Ibrahim Afellay and a header from youth team player Marc Bartra in the last 15 minutes sealed Barca's 30th win of the season.