The Catalan giants have now won all four of their league matches at the start of the 2018-19 campaign, but they had to ride their luck in the second period as Sociedad threatened a second on a number of occasions.
After a low-key start to the match, Sociedad took the lead in the 12th minute of the contest.
A deep free kick caused all sorts of problems inside the Barcelona box, and Hector Moreno's header dropped for fellow centre-back Elustondo, who smashed the ball in off the post to hand the home side the perfect start.
There was not too much in the way of an immediate response from Barcelona, with Sociedad - backed by a vocal home support - extremely comfortable as the first period continued to gather pace.
Lionel Messi sent one wide of the post from distance in the 26th minute, but the Argentine was quiet, while Luis Suarez and Dembele were also struggling to make their mark against the Basque outfit.
On-loan Real Madrid defender Theo Hernandez continued to break down the left for Sociedad, but there were often no targets to hit inside the box, with the home side missing main striker Willian Jose through injury.
Barcelona's best chance of the first period fell to Gerard Pique in the 36th minute, but the centre-back's header from a Dembele corner dropped wide of the post.
The visitors had a penalty shout just before the half-time break when Pique looked to be pulled to the ground inside the box, although the officials decided that there was not enough in it. Suarez then wanted a handball moments later following a challenge with Moreno, but that was also unsuccessful.
Philippe Coutinho came off the Barcelona bench at the interval, and the Spanish champions started the second period how they ended the first as Sociedad were forced to retreat. Chances were still few and far between, however, with the home side continuing to defend their lead.
Dembele connected with a Jordi Alba cross just before the hour, but the Frenchman's header was always moving away from the Sociedad goal as Elustondo's first-half strike continued to separate the two teams.
The home side had a golden chance to double their lead in the 59th minute when Ruben Pardo lead a counter before feeding Mikel Oyarzabal inside the Barcelona box, but the Spaniard fired over the crossbar.
The away side levelled the scores in the 63rd minute, however, when Luis Suarez smashed home from close range after a corner into the Sociedad box had caused all sorts of problems.
Another corner allowed Barcelona to complete the turnaround three minutes later, with Dembele reacting first to a loose ball. The Frenchman's effort took two deflections, but somehow headed up in the back of the net.
Messi fired a powerful effort over the Sociedad crossbar 10 minutes from time as the champions looked for a third.
Sociedad had a stunning chance to level in the final moments when Mikel Merino picked out the head of Juanmi, but the attacker headed wide of the post as Barcelona held on for the win, which has seen them move onto 12 points in La Liga.
REAL SOCIEDAD (4-5-1): Rulli; Zaldua, Aritz, Moreno, Theo; Zurutuza (Jon B 73'), Illarramendi (Merino 82'), Pardo (Sangalli 82'), Zubeldia, Oyarzabal; Juanmi
BARCELONA (4-3-3): Ter Stegen; Semedo (Coutinho 46'), Pique, Umtiti, Alba; Roberto, Rakitic, Rafinha (Busquets 57'); Dembele (Vidal 77'), Suarez, Messibody check tags ::