Barcelona moved another step closer to retaining their LaLiga title with a hard-fought 2-1 win over Real Sociedad.

Barca were far from their best and relied on goals from the unlikely duo of Clement Lenglet and Jordi Alba to see off a battling Sociedad side who briefly levelled through Juanmi but had chances to take far more from the game.

The win keeps Barca’s lead at nine points with five games to go after Atletico Madrid’s 1-0 win at Eibar earlier in the day.

Barca were slow to get going against a Sociedad side who defended impressively, with the only chances in the opening half an hour two Lionel Messi free-kicks – the first straight into the wall and the second narrowly over the bar.

Instead it was the visitors who fashioned the first clear opening when Ruben Pardo lifted a ball over the top which Juanmi perfectly chested down before shooting straight at the advancing Marc-Andre Ter Stegen.

The ball fell for Willian Jose but he could only poke over on the stretch.

That stirred Barca into action. Aritz Elustondo had to make a vital intervention to keep Jordi Alba’s low cross from Luis Suarez.

After Messi turned this way and that in a crowded area, Barca shuffled the ball over to Suarez whose first-time shot was well saved by Geronimo Rulli.

The breakthrough came with the last action of the first half when Lenglet got across his man on a corner to head in his first LaLiga goal.

Sociedad started the second half on top, with Mikel Oyarzabal and Jose threatening with headers before Pardo’s deflected shot was touched wide by Ter Stegen.

The Barca keeper had to scramble the ball away after a mix-up with Alba almost gifted the ball to Sociedad.

After Ousmane Dembele fired narrowly wide at the other end, Sociedad got a deserved equaliser in the 62nd minute. Mikel Merino’s superb pass split the Barca defence and the on-rushing Juanmi hooked the ball beyond Ter Stegen.

Parity lasted just two minutes, however, as Alba cut in from the left, switched the ball to his right foot and arrowed a shot beyond the reach of the Sociedad goalkeeper.

Ivan Rakitic should have wrapped it up with 11 minutes to go. Played in by Suarez, he broke into the box on the left side but fired into the side-netting as the angle tightened.

Arturo Vidal went close three minutes later but could not keep the ball down when it was flicked on to him at the far post after a Messi free-kick.

Ultimately Barca would not need a third as they got back to winning ways in LaLiga after last week’s surprise goalless draw with Huesca.