Leganes moved three points clear of the LaLiga relegation zone after edging to a 2-1 victory at fellow strugglers Rayo Vallecano despite finishing the fixture with 10 men.
On-loan Middlesbrough striker Martin Braithwaite opened the scoring after 36 minutes when he headed home from Jonathan Silva’s corner but Leganes’ hopes of holding on took a knock when Allan Nyom was dismissed.
The full-back, on loan from West Brom, saw red following a reckless challenge on Adrian Embarba just before the hour.
It seemed the man advantage played into Vallecano’s hands as Alvaro Garcia netted on the rebound in the 83rd minute after fellow substitute Jose Pozo’s initial shot had been saved.
But the hosts were level for barely two minutes before they conceded again, Youssef En-Nesyri heading beyond Stole Dimitrievski from Oscar Rodriguez’s corner.
It proved the decisive act of a feisty contest, in which 10 players were booked.
Defeat for 18th-placed Vallecano ended their impressive unbeaten run, having won four of their previous five fixtures, and they are now one point adrift of safety.
Stay updated with the latest news, gossip and football stories by following us @Football_P