Barcelona ground out a feisty 1-0 win at Real Sociedad on Thursday to tighten their grip on a top-four finish in LaLiga and put the disappointing home loss to lowly Cadiz behind them.

Barca climbed to second in the standings, level on points with third-placed Sevilla and 15 behind leaders Real Madrid.

Barca, who have a game in hand, host Rayo Vallecano on Sunday but Real Madrid need only four more points from their last five games to secure the title.

Pierre-Emerick Aubameyang scored Barcelona's winner on 11 minutes after Ousmane Dembele struck the post and Ferran Torres crossed to the Gabon striker who guided home a gentle header from close range.

It was an intense game at a packed Reale Arena in San Sebastian where the hosts wasted several clear opportunities to score and dominated possession.

Barcelona survived the Basque onslaught thanks to incredible misses by Alexander Isak and Alexander Sorloth and to inspired goalkeeping by Marc Andre ter Stegen who made at least three superb saves.

"It is the game that I have suffered the most since I arrived in November," Barca coach Xavi Hernandez told Movistar Plus.

"Real Sociedad dominated the game, they are a great team, they put us on the ropes and deserved more, perhaps a draw," he added.

"That is why it has been a vital win, a precious victory. It was a well fought and very important result that leaves us in second place, close to our objective of going to the Champions League next season."

Xavi said his team were exhausted in the second half, with several players in need of medical attention. Ronald Araujo and Dani Alves had to be substituted and Gerard Pique, Jordi Alba and Gavi struggled.

"It's a long season," Alves told reporters.

"With too many games in the last weeks the wear and tear takes a toll on us and it is normal for players to be tired. It's time for us to make an effort because there are few games left and we have to do everything to finish well."