Ten-man Leganes held on to secure a vital 2-1 victory over Rayo Vallecano to move three points clear of their relegation rivals in La Liga on Monday night.
Martin Braithwaite broke the deadlock after 36 minutes when the on-loan Middlesbrough striker met Jonathan Silva's corner to head home but Allan Nyom was then dismissed to put the visitors on the back foot.
The full-back's reckless challenge on Adrian Embarba just shy of the hour-mark handed Vallecano the momentum as Alvaro Garcia pounced to follow up Jose Pozo's initial shot with seven minutes remaining.
But parity lasted for just two minutes as Youssef En-Nesyri stole a yard to head in Oscar Rodriguez's corner.
Leganes now sit 13th, but are still only three points above Rayo, who currently occupy the final relegation spot.