Arturo Vidal scored the winner as Barcelona came from behind to beat Leganes in La Liga on Saturday.

Madrid (AFP) - Barcelona needed a late winner from Arturo Vidal to beat bottom-club Leganes 2-1 on Saturday and dig out a much-needed victory ahead of what could prove a crucial month in their season.

Vidal poked in a fortuitous goal in the 79th minute at Butarque after Luis Suarez headed home a Lionel Messi free-kick to cancel out a brilliant opener from Leganes forward Youssef En-Nesyri.

Barcelona stay top of the table, three points above Real Madrid, who play later on Saturday at home to La Liga’s surprise high-fliers Real Sociedad.

A gritty victory will also come as a relief to under-pressure coach Ernesto Valverde, whose team now turn their attention to Wednesday’s crunch Champions League group game against Borussia Dortmund at Camp Nou.

A goalless draw against Slavia Prague earlier this month means Barca’s qualification from Group F is no longer guaranteed.

After Dortmund, they then play away at Atletico Madrid in La Liga to start a month that will include trips to Inter Milan in the Champions League and Real Sociedad in La Liga before the season’s first Clasico at home to Real Madrid.

It was important therefore to avoid a slip against Leganes, playing their first game in front of their own fans since appointing Javier Aguirre as coach.

“It was a big win because the game was very difficult,” Valverde said. “The pitch was dreadful, there was a lot of wind and they scored early.

“I don’t want it to sound like an excuse but it made it hard and still we were able to win. It wasn’t a brilliant game but these are the ones you have to win to win the title.”

The home side made the perfect start as En-Nesyri beat Gerard Pique with a wonderful early striker.

Pique has spent the international break juggling football with the Davis Cup, the revamped tennis tournament in Madrid that he is organising through his marketing company Kosmos.

“There is more noise outside the club than inside,” said Pique after the match. “I think it’s got a bit out of hand - whether I’m in Madrid, eating here, having dinner there - it’s all part of the circus. But I do my job. I come here, I play football. And that’s it.”

Doubts about the defender’s focus would not have been allayed in the opening quarter of an hour.

One pass from Roque Mesa was enough to set En-Nesyri free against the 32-year-old in the 12th minute.

Pique jostled but was taken by surprise as En-Nesyri nipped inside and bent a shot into the far corner. Leganes might have had a second soon after and Pique would have been at fault, the defender allowing Martin Braithwaite in after failing to clear, but Oscar Rodriguez was unable to capitalise.

Crosses were a weakness for Leganes as three Barcelona headers all could have gone in. Suarez went close. Pique hit the post. Then Suarez did find the net, glancing in Messi’s clipped free-kick for his ninth goal of the season.

Barca’s second owed much to luck but it came from another cross. Pique rose to head in but the ball missed him and cannoned off the foot of Ruben Perez. Vidal was waiting on the line to prod in.