Earlier, Madrid had comfortably seen off Elche 3-0 at the Santiago Bernabeu thanks in part to a spectacular long-range strike from Gareth Bale. (Agencies)
Barcelona had come into the game on a high after beating Manchester City in their much-anticipated Champions League tie on Tuesday, but went behind when Alex Song turned Sergio Canales' cross into his own net.
Lionel Messi restored parity almost instantly with a clinical left-footed finish.
However, two goals in the opening 15 minutes of the second-half from Antoine Griezmann and David Zurutuza handed Sociedad a deserved victory.
"We didn't feel comfortable and we didn't have possession, which is our strength. That allowed then to create chances," Barca defender Gerard Pique told Spanish TV station Canal Plus.
"Now we have a week to rest and reflect on why things did't go well. It is not worrying, we just have to continue onto the next game."
Barca boss Gerardo Martino had made six changes from the side that started in Manchester as Neymar made his first start in a month.
After a slow start from the visitors, Pedro came close to opening the scoring when he sliced Andres Iniesta's pass just wide.
It was Sociedad who struck first, though, as Song bundled the ball into his own net under pressure from Gorka Elustondo.
The lead lasted only three minutes as Messi fired home his seventh goal in his last five games with an unerring finish from the edge of the area.
Sociedad should have been back in front before half-time when Carlos Vela pounced on an error from Gerard Pique, but the Mexican wastefully blasted over the bar with just Victor Valdes to beat.
Barca were dealt a blow at half-time when coach Gerardo Martino was sent to the stands for the second half after taking his protests towards the officials too far as they headed down the tunnel.
And the Catalans' defence also seemed to completely lose their composure at the start of the second-half as Sociedad opened them up at will.
Earlier, Madrid had comfortably seen off Elche 3-0 at the Santiago Bernabeu thanks in part to a spectacular long-range strike from Gareth Bale.