Arturo Vidal scored a scruffy late winner as La Liga leaders Barcelona came from behind to beat bottom club Leganes.
Youssef En-Nesyri's stunning early strike put Leganes ahead while Barcelona toiled in response.
The champions improved after the break and Luis Suarez equalised with a clinical header.
Vidal's finish put the leaders three points clear of rivals Real Madrid, who play Real Sociedad (20:00 GMT).
The Chilean midfielder's goal was fortuitous, Ousmane Dembele's corner deflecting kindly off Ruben Perez and falling to Vidal, who could not miss from a yard out.
Barcelona have lost three times away from home this season and looked nervy in the first half, deservedly falling behind when En-Nesyri picked out the top corner with a rasping shot after 11 minutes.
Oscar Rodriguez should have doubled the home side's lead but found the side-netting as their visitors struggled to get going in the final third.
After half-time, Barca centre-back Gerard Pique hit the post but they will be relieved to have escaped from this fixture with all three points.