Sevilla needed a late equalizer in a 1-1 draw at Atletico Madrid to clinch the final Champions League spot in the Spanish league on Sunday.
Barcelona secured second place, and a spot in the lucrative Spanish Super Cup in Saudi Arabia, after a 0-0 draw at Getafe, which escaped relegation.
A header by Youssef En-Nesyri in the 85th minute secured the point that gave Sevilla a place in Europe's top club competition for a third straight season. Third-place Atlético, which had already qualified, opened the scoring with José María Giménez in the first half.
A loss would have left Sevilla in a tense situation going into the final round next weekend as rival Real Betis beat Granada 2-0 to close in. The draw kept Sevilla three points ahead with a better head-to-head tiebreaker against fifth-place Betis.
"Mission accomplished," Sevilla coach Julen Lopetegui said. "What a great season! The team deserved this prize."
Manuel Pellegrini's Betis had already secured a Europa League place by winning the Copa del Rey, and it will be joined in the second-tier competition by sixth-place Real Sociedad, which defeated Villarreal 2-1 on Sunday.
Villarreal and Athletic Bilbao, which beat Osasuna 2-0, will fight next weekend for a spot in the third-tier Europa Conference League. Villareal visits Barcelona, while Bilbao is at Sevilla.
Real Madrid, which had already clinched the title and is focused on the Champions League final against Liverpool on May 28, drew 1-1 at Cádiz.
Alavés became the second team relegated after a 3-1 loss at Levante, which had been demoted in the previous round.
Granada, Mallorca and Cádiz will fight to avoid relegation in the final round.
Unai Emery's Villarreal had a chance to stay alive in the fight for a Europa League spot but it allowed visiting Sociedad to rally to victory in the second half to secure the final spot in the second-tier competition.
Villarreal, which made it to the Champions League semifinals this season, is now in danger of missing out on the final Europa Conference League berth as well after Bilbao moved within a point of seventh place. Bilbao holds the head-to-head tiebreaker against Villarreal.
Mallorca moved out of the relegation zone thanks to a stoppage-time goal by Abdón Prats in a 2-1 home win over Rayo Vallecano.
"It was incredible," Prats said. "Hopefully this goal can keep the team in the first division."
The victory left Mallorca just outside the relegation zone, tied on points with Cádiz but ahead on the head-to-head tiebreaker. A win at midtable Osasuna next weekend will guarantee the club owned by American businessman Robert Sarver stays in the top flight. Cádiz will play at last-place Alavés.
Granada, sitting one point ahead of Mallorca, will host Espanyol in the final round.
Striker Luis Suárez became emotional as he received a huge ovation from Atlético Madrid fans after being substituted in the second half of what was likely his last match with the club.
"Thanks for making us champions," said a banner at the Wanda Metropolitano Stadium.
Suárez was key in the team's title run last season after joining from Barcelona, but gradually lost his starting place and only played a few minutes off the bench recently.
Atlético is five points behind Barcelona, which got the result it needed against Getafe to secure the Spanish Super Cup berth in advance.
Focused on Liverpool, Madrid coach Carlo Ancelotti again rested some of his starters — including striker Karim Benzema, forward Vinícius Júnior, midfielder Luka Modric and goalkeeper Thibaut Courtois — in the draw at relegation-threatened Cádiz.
Cádiz missed a chance to leave with the victory when forward Álvaro Negredo had his 61st-minute penalty kick saved by Madrid's Ukrainian goalkeeper Andriy Lunin. The home win would have put Cádiz two points outside the relegation zone.
Cádiz won one of its last five matches after a shock 1-0 win against Barcelona at the Camp Nou Stadium.
Madrid enters the final round with 85 points, 12 more than Barcelona.