Malaga missed the chance to go third in La Liga when they conceded two late goals to lose 2-1 at Villarreal on Thursday.
It seemed that a win was on the cards for the Andalusian side when Santi Cazorla put them ahead on 65 minutes.
But it all went wrong on 80 minutes when goalkeeper Carlos Kameni was sent-off for bringing down substitute Hernan Perez.
Marcos Senna converted the penalty and, in the fourth-minute of injury time, Perez shot home from the edge of the area to give a much-needed win to Villarreal who started the evening only four points above the relegation zone.
Malaga remain in fourth place and still in a Champions League place on 50 points, two ahead of fifth-placed Levante.
The night got better for Villarreal when other results confirmed defeats for two of their nearest rivals at the bottom of the table.
Zaragoza went down 3-0 at Sevilla and bottom club Racing Santander lost 3-0 at home to Mallorca to leave both teams struggling in the relegation zone, seven and 10 points behind Villarreal and safety.
Emilio Nsue put Mallorca ahead on 20 seconds in Santander and Chori Castro scored within 60 seconds of the restart before Alejandro Alfaro fired home a third to put Mallorca safely into 12th position.
Spain striker Alvaro Negredo scored two first-half goals for Sevilla to make it 10 goals for the season after Fazio had opened the scoring.
The result leaves Sevilla in seventh position, just a point behind Osasuna in sixth place and entry into next season's Europa League.
Leaders Real Madrid beat Atletico Madrid 4-1 on Wednesday to go four points clear of Barcelona with six games remaining.