The hosts started the game on the front foot but Sociedad got the opening goal against the run of play.
A beautiful team move was rounded up when Portu squared the ball across the goal for Willian Jose to tap into an empty net.
The visitors were lucky to have not been reduced to 10 men early on as Adnan Januzaj was only shown a yellow card for a nasty elbow on Antoine Griezmann when he could easily have been sent down the tunnel.
Their lead, however, lasted for only four minutes, as Jordi Alba leveled matters in the 31st minute with an exquisite belter.
A cross by Antoine Griezmann was nodded into the path of the Spain international, and he scored his first goal of the season with a right-footed curler which found the top corner.
Griezmann hit the bar soon after, and Martin Braithwaite somehow failed to convert on the rebound pass from Pedri. However, Barcelona got the lead that their dominance deserved four minutes before half-time.
Frenkie de Jong was on hand to convert a square ball by Alba in the 41st minute which was initially ruled out for offside. However, VAR checks confirmed that the Netherlands international was onside in the build-up.
The second half took a while to spark to life but Alexander Isak had a great chance after he was played in on goal. An excellent tackle by Pedri right on the goal line prevented the equalizer, although it came at a cost as he crashed into the post while making the tackle.
Real Sociedad cracked up the pressure in the final 15 minutes of the game but could not breach the Barcelona rearguard.
There was a moment of panic for the hosts when Lionel Messi was clattered from behind by Robin Le Normand but the skipper got right back up despite initial fears.
The hosts had goalkeeper Marc Andre Ter Stegen to thank for preserving their lead after he made two quickfire saves from no Willian Jose and Alexander Isak in the 85th minute.
Ultimately, Barcelona held on for the win to move up to 5th on the standings. Here, we shall be highlighting five talking points from the fixture.
#5 Barcelona post statement victory
Barcelona have started this season slowly and came into this clash in 8th place, having won just five of their opening 11 games.
They scraped their way to a 1-0 victory over Levante last weekend and followed that up with another hard-fought victory at Camp Nou.
Real Sociedad have been one of the form teams in La Liga this season and are currently joint-top on the standings. Hence, this victory will go some way in boosting the confidence within the Barcelona camp.
The victory saw Barcelona extend their winning run at home to Real Sociedad, with this being their 23rd consecutive victory over Txuri-urdinak.
Although they held on for dear life for most parts of the game and would have failed to pick up the win had their visitors been more clinical, the three points are all that matters and would go some way in easing the pressure on Ronald Koeman.
#4 Real Sociedad fail to take opportunities
Real Sociedad came into this fixture on the back of three consecutive draws, and this saw them lose their initial advantage at the summit of the table.
A three-way tie at the top had Real Madrid, Atletico Madrid, and Sociedad all level on 26 points but a victory here for the Basque side would have seen them go three points clear of the capital teams.
They faced a Barcelona side that have been far from convincing and would have fancied their chances of picking up a first victory at Camp Nou since 1991.
Their hopes were given a massive boost when they went ahead inside the first half-hour of the game. However, the visitors stayed in front for less than four minutes.
A poor first-half showing was duly punished when the Catalans went ahead through Frenkie de Jong just before half-time.
Real Sociedad started the second half more brightly and put Barcelona on the back-foot, with several top quality chances created, which they failed to convert.
This defeat sees them drop into second place behind Atletico on goal difference. Having played three games more than Diego Simeone's side, Real Sociedad will be frustrated at having failed to make their pressure count.