Leganes lived to fight another day in La Liga, riding their luck in a 1-0 win at home to Valencia on Sunday.
This was after they played most of the second half with 10 men and saw their opponents squander a penalty kick.
Midfielder Ruben Perez put the Madrid minnows in front in the 18th minute from the penalty kick spot, scoring his first goal since 2013.
But his side suffered a setback when Jonathan Silva was shown a straight red card in the 54th minute.
Valencia earned a penalty kick soon after, following a handball by Leganes’ Rodrigo Tarin.
But team captain Dani Parejo’s penalty kick was beaten away by goalkeeper Ivan Cuellar and Leganes somehow clung on to record a first home victory since February.
Defeat would have condemned Leganes to relegation, while the win saw them instead move up to 18th place in the standings on 32 points with two games remaining.
They are three points behind 17th-placed Alaves who have a game in hand.
Valencia are ninth on 50 points.
Elsewhere, Eibar practically sealed their top flight status by beating relegated Espanyol 2-0 away from home.
Edu Exposito scored both goals to earn Eibar their first win in four matches, giving them the lead by converting a penalty kick in the 25th minute.
The visitors won a second penalty kick soon after and Exposito’s effort was saved by Espanyol goalkeeper Diego Lopez.
But the midfielder pounced on the rebound to double his side’s advantage in the 36th minute.
The victory took Eibar up to 15th in the standings on 39 points.
They will be guaranteed survival if Real Mallorca, also in the relegation zone on 32 points, lose at fourth-placed Sevilla later on Sunday.
Espanyol, relegated on Wednesday, stayed rooted to the bottom of the table on 24 points after losing a seventh successive game.
Also on Sunday, Athletic Bilbao won 2-1 away to Levante thanks to two goals from Raul Garcia to move into seventh place, the final Europa League berth, on 51 points.