Barcelona and Real Madrid will go head to head for the La Liga title next weekend, but Atletico Madrid have dropped out of the race after their shock 2-1 defeat at Levante.
League leaders Barcelona would have won the title on the penultimate matchday with a win over Espanyol, providing that Atletico lost at basement side Levante and Real Madrid failed to win at home to Valencia.
Barcelona kept to their end of the bargain with a 5-0 success over their Catalan rivals, but Real Madrid's 3-2 home victory over 10-man Valencia means that the race for the championship will enter the final weekend.
On Sunday, Barcelona will visit already-safe Granada, while Real Madrid will make the trip to Deportivo La Coruna.
Levante have already been relegated to the Segunda Division and they will be joined by two from Rayo Vallecano, Sporting Gijon and Getafe after week 37's results.
Celta Vigo boosted their chances of a top-five finish with a 1-0 win at Malaga, but Athletic Bilbao's point at Las Palmas means that the race for fifth will also go to the final weekend.
Eibar and Real Betis played out a 1-1 draw in the Basque country, while Getafe and Sporting Gijon also shared the points as both missed out on the chance to secure safety ahead of the final weekend.
Real Sociedad recorded a 2-1 win over Rayo to leave Paco Jemez's side in deep trouble, but Granada, who host Barcelona next weekend, are now safe after recording a 4-1 victory at Sevilla.
Villarreal have already secured fourth position ahead of week 38, but they finished at El Madrigal with a 2-0 loss to Deportivo.
La Liga results, week 37:: Barcelona 5-0 Espanyol; Celta Vigo 1-0 Malaga; Eibar 1-1 Real Betis; Getafe 1-1 Sporting Gijon; Las Palmas 0-0 Athletic Bilbao; Levante 2-1 Atletico Madrid; Real Madrid 3-2 Valencia; Real Sociedad 2-1 Rayo Vallecano; Sevilla 1-4 Granada; Villarreal 0-2 Deportivo