Real Sociedad took a huge step towards qualifying for the Champions League next season as they came from behind to beat Valencia 4-2 at Anoeta.
Roberto Soldado had headed the visitors into an early lead but Inigo Martinez levelled with a sweet volleyed finish 11 minutes before the break.
Chori Castro then finished off a wonderful counter-attack to give Sociedad the lead on 73 minutes and Imanol Agirretxe looked to have sealed the points four minutes from time.
Jonas momentarily put the outcome back in doubt as he halved the deficit but Agirretxe rounded off the scoring with a beautiful chip over Diego Alves in the last action of the game.
The win moves Sociedad five points clear of both Valencia and Malaga in fourth place with just five games remaining.
"We are happy with this result, the manner with which we played and most importantly the result," Sociedad boss Philippe Montanier told a press conference afterwards.
"It was a great game for everyone involved with Real Sociedad. The atmosphere created by the fans was great and the players fed off that."
However, it had been Valencia who got off to the best possible start with a wonderfully worked goal on 25 minutes as Soldado showed great movement to get on the end of Aly Cissokho's cross and flicked his header inside the far post.
Soldado was up in arms moments later, though, as referee David Fernandez Borbalan failed to see a clear handball by Claudio Bravo outside his area, which took the sting out of Soldado's attempted lob and allowed Mikel Gonzalez to clear.
And having been given a lifeline, Sociedad were soon level as a well-worked corner on the left created space for Castro to cross and he picked out Martinez at the back post to volley home in style.
Sociedad went in front 17 minutes from time thanks to a stunning counter-attack from a Valencia corner as Castro and Agirretxe exchanged passes on two occasions before the former slotted neatly past Diego Alves.
The Brazilian keeper then kept his side in it with fine saves from Vela and Agirretxe.
However, he was beaten again four minutes from the end as Agirretxe turned home Xabi Prieto's cross.
Jonas pulled one back with a header from close range as the game entered stoppage time after Bravo could only parry Pablo Piatti's effort.
But the home fans' nerves were eased moments later as Agirretxe produced another stunning finish to move Montanier's men to within touching distance of a first Champions League campaign in 10 years.
Elsewhere, Malaga moved level with Valencia in fifth with a routine 2-1 win over Getafe.
Roque Santa Cruz and Weligton got the goals for the hosts just before and after half-time and despite Juan Valera's reply 20 minutes from time, Getafe's own European hopes are dwindling after a third consecutive defeat.
At the bottom Granada gave their hopes of survival a big boost with their first win in 10 games at Espanyol.
Nolito scored the only goal of the game with a stunning free-kick seven minutes before half-time, which moved Lucas Alcaraz's men out of the relegation zone and up to 16th.
And in the clash between two sides stuck in mid-table mediocrity, Valladolid and Sevilla shared the points in a 1-1 draw.
Javi Guerra put Valladolid ahead four minutes before half-time but Alvaro Negredo levelled from the spot just after the hour mark when Marc Valiente was harshly adjudged to have deliberately handled inside his own area.