The Uruguayan footballer Diego Forlan helped Atletico Madrid secure a place in Champions League qualifying with his 32nd Primera Liga goal of the season in a 3-0 win over visiting Almeria.
Abel Resino's side had needed only a draw to fight off the challenge from fifth-placed Villarreal, who won 3-2 at Real Mallorca thanks to a double from Joseba Llorente.
Champions Barcelona, runners-up Real Madrid and third-placed Sevilla had already secured the three automatic places in Europe's elite club competition.
Barca closed out their treble-winning season with a 1-1 draw at Deportivo Coruna, after Samuel Eto'o grabbed a late equaliser for his 30th goal of the campaign.
Villarreal will play in the Europa League, which replaces the UEFA Cup from next term. They will be joined by Valencia, who made sure of sixth spot thanks to David Villa's 27th and 28th goals of the season in a 2-0 win over visiting Athletic Bilbao.
Deportivo finished just outside the Europa League places in seventh, four points behind Valencia.