Substitute Arturo Vidal rescued Barcelona with a scrappy late goal as the leaders of LaLiga recovered from an early setback to win 2-1 at bottom side Leganes on Saturday.

Barca boss Ernesto Valverde fielded an attacking line-up that included Lionel Messi, Antoine Griezmann, Luis Suarez and Ousmane Dembele in a 4-2-3-1 formation, but it did not look like paying off for large parts.

Leganes have won just once all season but the underdogs took the lead through Youssef En-Nesyri's sublime early strike, before the champions hit back in the second half.

Suarez dragged his side back on level terms and Vidal scored in fortuitous fashion 11 minutes from time to move Barca three points clear at the summit, the winning goal allowed to stand after a VAR check showed the midfielder was not offside due to the ball reaching him via a Leganes player.

Barcelona lost 2-1 at Leganes last season and were behind inside 12 minutes on this latest trip, En-Nesyri cutting inside on his left and curling the ball into the top-left corner.

Suarez wasted a couple of promising opportunities before forcing an excellent fingertip save from Ivan Cuellar with a header from Dembele's cross.

But the Uruguay international found a way through eight minutes into the second half after being left free on the edge of the six-yard box to head in Messi's free-kick.

Barcelona took control of the contest but were left frustrated until Vidal struck 22 minutes after being introduced from the bench.

Vidal was left in space to bundle the ball past Cuellar from close range after Dembele's corner deflected into his path, the touch off the leg of Ruben Perez ensuring the goalscorer was onside despite Leganes' protests.