Gabri Veiga scored twice as Celta Vigo beat champions Barcelona to ensure a 12th straight season in La Liga.
Celta went into the final day one point above the relegation zone but Veiga, 21, struck just before half-time, then fired in his 11th goal of the season.
Spain forward Ansu Fati, 20, pulled one back with a late header but Celta held on to secure a 13th-place finish.
Real Valladolid were relegated after a 0-0 draw at home to Getafe saw them stay in the bottom three.
They had only been promoted last season and will now return to Spain's second tier with Espanyol and Elche, whose fate had already been sealed.
Barca's defeat means they have lost three of their four games since beating Espanyol to clinch their first league title since 2018-19.