Gerard Pique opened the scoring for Barca with a powerful header from Memphis Depay’s free-kick.
Martin Braithwaite scored either side of half-time to become the first Danish player to score a La Liga brace.
Real Sociedad pulled it back to 3-2 through Julen Lobete and Mikel Oyarzabal but Sergi Roberto added a fourth for Barcelona in injury time.
It was fitting that Barca’s first goal of the season was scored by Pique after the defender agreed to reduce his wages earlier in the week so the club could register three new signings in time for the new season.
Many of the 22,000 Barcelona fans wore Messi shirts to the Nou Camp and chanted for their record goalscorer in the 10th minute after he joined PSG on a two-year deal earlier in the week.
New signing Sergio Aguero, who has been ruled out for 10 weeks with a calf injury, watched from the sidelines.