La Liga leaders Barcelona extended their unbeaten run to 24 games but were far from their best in a narrow victory at relegation-threatened Leganes.
They needed an own goal by Jorge Saenz to get over the line - the home defender forced into the error from Raphinha's tantalising cross, with Robert Lewandowski lurking ominously behind him for a tap-in.
Leganes, who are two points from safety but won the return fixture between the sides in December, had the better chances in the first half - Adria Altimira forcing a good save from Wojciech Szczesny, and Dani Raba twice going close.
Hansi Flick's visitors seemed to gain some control after going ahead, Fermin Lopez inexplicably shooting wide after some fine skill in a tight penalty area, but they had to ride their luck with Raba having a goal chalked off for offside and substitute Diego Garcia sliding wide when well-placed to score.
The win extends Barcelona's lead at the top to seven points, before arch-rivals Real Madrid's trip to struggling Alaves on Sunday (15:15 BST).