Coming into the contest on the back of seven successive wins across all competitions, Hansi Flick’s side looked full of confidence in the opening exchanges.
Barca thought they’d taken an early lead when Robert Lewandowski found the net with a well-taken finish but the Pole saw his goal chalked off for a marginal offside.
Grateful for that reprieve, the hosts grew into the match as the first half progressed and came close to a breakthrough, with Brais Mendez and Takefusa Kubo seeing a pair of efforts thwarted by Inaki Pena.
Sociedad continued to cause Barca problems at the back and their pressure was duly rewarded in the 33rd minute when Luka Sucic’s flick-on was clinically converted into the far corner by Sheraldo Becker.
Armed with the momentum, Alguacil’s men spurned a glorious chance to double their lead before half-time as Mikel Oyarzabal fired wastefully wide from Becker’s inch-perfect delivery.
Having lost four of their six league matches on home soil this season, Sociedad looked determined to press home their advantage at the start of the second half.
However, Pena came to Barca’s rescue once again, saving smartly from Oyarzabal’s close-range effort, while at the other end, Fermin Lopez blazed over a rare opening for the subpar visitors.
The match remained tantalisingly poised heading into the final 20 minutes, with Ander Barrenetxea wasting another promising opportunity for the hosts when his scuffed strike bobbled narrowly wide of the near post.
Sociedad’s profligacy in front of goal kept the Blaugrana’s hopes of a late leveller alive, but despite seeing plenty of the ball in the closing stages, the visitors failed to create anything of note, falling to a first defeat in eight matches.
As for Alguacil’s men, they move into the top half of LaLiga, two points adrift of the European spots.