The defeat was Real Sociedad's first away from home this season and allowed Atletico Madrid to leapfrog them at the top of the table on goal difference.
Barca were good for 45 minutes and were unlucky to go behind. They could have scored three or four in the first half, settling for two as they came from behind to win for the first time this season. After the break, they showed the other side of their game, digging in to hold on to their lead as La Real pushed. This was Barca's most complete performance in La Liga in months.
Coach Ronald Koeman's main complaint this season has been failing to take chances and that was again Barca's problem here -- although it didn't come back to haunt them this time.
Antoine Griezmann was good, took up good positions and that's why he had so many chances, but some of his misses, namely the one from two yards in the second half, were unforgivable. Martin Braithwaite also missed a good chance and Barca were forced to hang on at the end.
Manager rating out of 10
6 -- Koeman was rewarded for his bravery in playing Araujo and Mingueza ahead of the more experienced Clement Lenglet, while Pedri was a much better fit in the midfield three than Philippe Coutinho was on Sunday against Levante.
Player ratings (1-10; 10 = best. Players introduced after 70 minutes get no rating)
DF Sergino Dest, 6 -- Good cross for Pedri to head just wide early on and worked hard in defence.
DF Ronald Araujo, 6 -- Strong and speedy but a bit rash. Got away with a couple of challenges in and around the box that could have been penalised.
DF Oscar Mingueza, 7 -- Played well. Quick across the ground and good on the ball. That said, his sole mistake nearly led to a goal for Real Sociedad. Luckily Pedri got back to help him out.
DF Jordi Alba, 8 -- Took his goal brilliantly on his weaker right foot, set up the other goal for De Jong, and put another on a plate for Griezmann. Now has six assists and one goal to his name this season.
MF Sergio Busquets, 6 -- Another discrete performance that ended early in the second half after a booking for a clumsy challenge.
MF Frenkie de Jong, 7 -- A second encouraging performance in a week. Has more license to get forward in a three-man midfield and crowned his display with a goal.
MF Pedri, 7 -- Doesn't stop running and pressing but can also play. Had highlights at both ends: brilliantly set up Braithwaite in the first half and tirelessly covered for Mingueza in the second half, taking a whack of the post in the process.
FW Antoine Griezmann, 6 -- Missed a sitter from two yards but played well and could have scored three on another night. Also, hit the underside of the bar and saw another shot well saved.
FW Lionel Messi, 7 -- His fingerprints were on both goals despite not setting them up. Played unselfishly for large parts of the night.
FW Martin Braithwaite, 6 -- Worked hard and offered pace and strength out wide. Missed a great chance.
MF Carles Alena, 5 -- A couple of nice runs off the ball but too imprecise on it.
FW Francisco Trincao, 5 -- A couple of nice touches but gave the ball away in dangerous areas.
MF Miralem Pjanic, N/R -- Brought on for Pedri after he hurt himself sliding into the post.
DF Clement Lenglet, N/R -- Came on for Mingueza who was struggling with cramp late on.