Hernan Perez struck deep into injury time as Villarreal scored twice in the final 10 minutes to come from behind and beat Malaga 2-1.
After an early Marcos Senna effort had rattled the crossbar it was the visitors who largely controlled proceedings and they deservedly took the lead when Santi Cazorla came back to haunt his old club with a left-foot shot from the edge of the area that gave Diego Lopez no chance.
However, Villarreal rallied in the final quarter and were handed a route back into the game when Carlos Kameni up-ended Perez in the box with seven minutes remaining. The goalkeeper was sent off and Senna duly tucked away the penalty.
And Perez capped a remarkable comeback four minutes into stoppage time as he slammed the ball home from outside the box to give Villarreal a vital three points in their battle to avoid relegation from the Primera Division.
A brace from Alvaro Negredo and one from Federico Fazio steered Sevilla to a comfortable 3-0 victory over relegation-threatened Real Zaragoza at the Estadio Sanchez-Pizjuan.
Fazio headed the first after 10 minutes and Spain forward Negredo took his goals tally to 10 with efforts in the 29th and 44th minutes.
The win took Sevilla up to seventh while Zaragoza remain second-bottom, now seven adrift of Villarreal after their win over Malaga earlier.
Racing Santander remain marooned at the bottom after Mallorca secured their survival with a 3-0 win at El Sardinero.
The visitors got off to a dream start as Victor Casadesus' pass split the Racing defence wide open and Emilio Nsue ran through to round Dani Sostres and roll the ball home.
Christian Stuani should have equalised when he struck the post midway through the first half but Mallorca wrapped up the points within eight minutes of the break as Chori Castro doubled their advantage from another Victor assist before Alejandro Alfaro bundled in a third after Nsue had hit the crossbar.
Racing have now lost six of their seven games since Alvaro Cervera took charge and they could not have got off to a worse start as Victor's quick thinking released Nsue to race beyond the hosts' static back line and the Spain Under-21 international coolly finished to register his third goal of the season.