Barcelona manager Quique Setien admitted his side had to ride their luck early on against Leganes before claiming a 2-0 win inside an empty Camp Nou that reestablished a five-point lead over Real Madrid in La Liga.
Playing their first home game since the Spanish league season resumed after the three-month coronavirus lockdown, Barca claimed a second win from as many matches courtesy of teenage forward Ansu Fati's opener and Lionel Messi's penalty.
The defending champions were far from their best and could have gone behind on two occasions before 17-year-old Fati put them ahead in the 43rd minute, for his fifth league goal of the season.
Messi doubled the home side's advantage from the penalty spot in the 69th minute, almost immediately after Antoine Griezmann had a goal ruled out for offside following a VAR review.
It was Messi's 56th converted penalty in La Liga and saw him draw level with Hugo Sanchez as the league's second-top penalty taker, behind record holder Cristiano Ronaldo on 61.
"We had a bit of luck at the beginning," Setien said.
Barca lead the standings on 64 points after 29 games, five ahead of nearest challengers Real Madrid who are in action at home to Valencia on Thursday. Leganes meanwhile are bottom with 23 points.
"It's important to keep winning although we need to play with more speed than we did today but we've got six points and we're going to get better in each game," said Barca midfielder Ivan Rakitic.
"All teams have a lot at stake at this stage so we expected a tough game, they made it difficult for us to find space and they committed a few fouls but things got easier as the game went on."
Barca had enjoyed a dream return to action by thumping Real Mallorca 4-0 while Leganes were beaten at home by Real Valladolid in their first game back, but the minnows produced a brave display and should have made more of their bright start.
Barca defender Clement Lenglet had to scramble clear a shot from Leganes forward Miguel Angel Guerrero early in the game and moments later Guerrero struck the post from a tight angle.
Barca's Camp Nou is far from the most atmospheric of stadiums in Spain but this time there were no fans at all to give the team a boost as spectators are currently barred from all La Liga matches for safety reasons due to the Covid-19 pandemic.
The 99,000-capacity arena last stood empty for a league game when Las Palmas visited in a 2017 fixture which was played without fans as a protest against a police crackdown during Catalonia's banned referendum on independence.