Their perfect start to the LaLiga campaign looked in danger of coming to a crashing halt as Aritz Elustondo's fine finish early on gave the hosts the lead.
Sociedad squandered three glorious opportunities on the break in quick succession just before the hour to put the game out of sight, profligacy that was duly punished by the ruthless visitors.
Luis Suarez was quickest to react to a loose ball from a goalmouth scramble to level in the 63rd minute before Ousmane Dembele's low effort took two deflections on its way into the net to secure maximum points for the Catalan side just three minutes later.
Sociedad had started brightly and were rewarded in the 12th minute when Elustondo lashed in a superb half-volley after Hector Moreno's back-post header was deflected into his path.
Barcelona struggled to get a foothold in the game after that early setback, but could have twice levelled through Gerard Pique shortly before the interval.
Barca threw Philippe Coutinho on at the break in an attempt to inject some life into their listless attack, but it was the hosts who looked most likely to score the next goal.
In a remarkable passage of play, Sociedad missed three one-on-ones in the space of four minutes. Mikel Oyarzabal flashed over after springing the offside trap, before Marc-Andre ter Stegen thwarted Theo Hernandez and Juanmi.
Those misses came back to haunt them almost immediately as Suarez thumped home from close range and then Dembele took advantage of poor defending from a corner to scuff home from 15 yards.
Juanmi should have snatched a late point for the hosts, but his free header sailed agonisingly wide as Barca ultimately held on for a fourth LaLiga win on the spin.
What it means: Barca setting the pace
They were some way off the side that thumped Huesca 8-2 before the international break, but Barcelona proved they can win ugly – often the sign of champions. They can now sit back and see if Real Madrid can keep pace when they visit Athletic Bilbao later on Saturday.
Pat on the back: Dembele finding his feet
It has not always been plain sailing for Dembele following his big-money move from Borussia Dortmund at the start of last season, but the young Frenchman continued his impressive start to this campaign. His winning goal makes it three in four league games.
Boot up the backside: Pique out of sorts
He missed two chances to equalise in the first half and generally looked sluggish at the back all afternoon. He can consider himself lucky that Sociedad did not punish him with any of those three glaring one-on-one chances.
Key Opta facts:
- Ousmane Dembele has won more points with his goals than any other player in LaLiga this season (three goals, four assists).
- Since the start of 2017-18, Barcelona have won a league-high 23 points from losing positions in LaLiga.
- Dembele has been involved in 13 goals in his last 16 starts for Barcelona in all competitions (eight goals and five assists).
- Luis Suarez has had a hand in eight goals in eight games against Real Sociedad in LaLiga (four goals and four assists).