Seydou Keita scored a late equaliser for Barcelona as they were held to a 2-2 draw by Real Betis in a topsy turvy encounter that was Pep Guardiola's final league match in charge of the Catalans.
Sergio Busquets put Barca ahead in the ninth minute of a first half they dominated but Betis responded well in the second half and they took advantage of Dani Alves' sending off in the 53rd minute.
The impressive Ruben Castro scored two sublime goals in three minutes and Betis were on course for victory before Keita headed home 90 seconds into injury time.
Real Sociedad ended the Primera Division season on a high as Antoine Griezmann's second-half goal saw off Valencia 1-0 at Anoeta on Saturday night.
With both sides having little to play for, the game started slowly, but it improved improved after the break as Aritz Aduriz and Pablo Hernandez passed up chances to give the visitors the lead.
Instead Sociedad got the winner midway through the second half as Griezmann slid in to meet Xabi Prieto's cross for his third goal in four games to seal a 12th-placed finish for the Basques, their best in the top flight since coming second in 2003.