Goals from Lionel Messi and Pedro put the visitors in the driving seat, but Chori Castro pulled one back in the first period, before Sociedad staged a second-half fightback.
Castro claimed a second courtesy of a deflection off Javier Mascherano and substitute Imanol Agirretxe sealed the points with a stoppage-time winner, condemning Barca to their first defeat of the season.
Find out how the action unfolded with our minute-by-minute text commentary below.
4.47pmGood afternoon and welcome to our live coverage of the La Liga clash between leaders Barcelona and Real Sociedad. We'll have both starting lineups for you in just a moment...
4.52pmREAL SOCIEDAD: C.Martinez, Mikel, Inigo, De la Bella; Markel, Illarra, Xabi Prieto; Griezmann, Vela, Castro
4.55pmThe hosts have a huge task on their hands tonight. Barca are running away with La Liga and have dropped just two points all season thanks to that draw with Real Madrid. Not to mention the fact that Tito Vilanova's side have already thrashed them 5-1 this season.
2 minBarca go straight on the attack with Fabregas playing the ball in from midfield. The Sociedad defence deal with the threat well, but I get the feeling they are in for some heavy bombardment this evening.
5 minCHANCE! World player of the year Messi beats the offside trap but shoots wide to the right of Martinez's post. Great vision from Iniesta to pick him out, but the finish was lacking by the Argentine's own high standards.
7 minThe Barca frontman makes up for his earlier miss with a brilliantly-taken goal. Iniesta provided the pass once again, and the striker found the bottom-left corner with a vicious strike from inside the box. Messi doesn't miss twice!
10 minBarca are up and running now and are controlling the game in the manner we are accustomed to. Play is interrupted as Sergio Busquets commits the first foul of the match to hand Sociedad a free kick, but Carlos Vela fails to create anything from it.
11 minCHANCE! Sociedad's first chance of the afternoon falls to Xabi Prieto, who shoots wide to the left after being played in by Gonzalo Castro. I think Valdes would have made short work of that had it been on target.
14 minOFF THE POST! Barca continue to put the hosts under intense pressure as Pedro watches his vicious right-footed shot come crashing back off the post. The move then grinds to a halt as Dani Alves fouls Gonzalo Castro.
17 minCHANCE! Barca may be in the ascendency, but it isn't all one-way traffic. Antoine Griezmann shoots narrowly wide to the right of Valdés's post. The visitors are the better team, but Sociedad are refusing to lie down!
19 minIt's been a good game. Both sides have had their chances on goal, but it has become stop-start in the last few minutes. Griezmann just gifted a free kick to Barca and Dani Alves committed a foul at the other end of the pitch almost immediately after.
26 minWhat a wonderful team goal from Barca! Xavi played in a brilliant ball over the top for Dani Alves to beat the offside trap, and the Brazilian pulled it back across the face of goal to hand Pedro a tap-in. Sociedad have a mountain to climb now!
28 minAnother great run from Dani Alves as the full-back latches onto another long ball. He plays a cross into the box but Inigo Martínez heads it behind. The attack draws to a halt when Carles Puyol handballs.
30 minHalf an hour played and goals from Messi and Pedro separate the two teams. The Catalans are just so effective at punishing teams for every little mistake they make. Sociedad have played fairly well, but Barca have exploited them at every opportunity.
33 minBOOKING! Gerard Piqué gets the first yellow of the afternoon for dissent. He was needlessly disputing a clear-cut Dani Alves foul, for which the referee awarded a free kick. A needless booking.
35 minSociedad have the ball in the net, but two of their players were offside and the goal doesn't stand. The linesman was early with his flag and the decision was the correct one.
36 minBOOKING! Iñigo Martínez is the first Sociedad player to go in the book for a bad tackle on Messi. He went in hard and missed the ball, leaving the ref with no choice but to caution him.
39 minCHANCE! Oh my word! How did that stay out. Messi uses his lethal pace to latch onto Xavi's pass. Sociedad keeper Martinez commits himself but Messi chips the ball over him and it comes back off the post and rolls along the line without crossing it, allowing the home defence to clear. What a let-off for the home side.
42 minA stunning turn of events as Sociedad pull a goal back moments after Messi hit the post at the other end. Carlos Vela found Gonzalo Castro in the box and he lashes one beyond Valdés into the bottom right corner to reduce the deficit!
43 minSHOT! Castro could have had two in as many minutes were it not for Valdes in the Barca goal. He found space in the box again, but directed his effort straight at the keeper!
44 minSAVE! What a refreshingly-open game this has been! Martinez just produced a top save to deny Messi his second of the afternoon. The Argentine unleashed a vicious strike from inside the box, but the shot-stopper made himself big to turn it behind.
5.48pmThat first 45 minutes was a great advert for the Spanish game. It's been a very open match with plenty of chances falling to both sides. Barca have edged it, but Sociedad haven't let them rest on their laurels.
5.50pmI think there could be more goals in this one, certainly. Messi has scored for 10 games running now and could have had a hat-trick in that first half. Castro has been a live wire at the other end, so we should write Sociedad off by any means.
5.54pmThe next goal is bound to be a hugely significant one. 3-1 Barca would likely make it game over, but if Sociedad were to equalise anything could happen. I personally think Barca have it in the bag, though. My money is on Messi as next goalscorer.
47 minSociedad are the first side to string an attack together in the second period, but they are stopped in their tracks as Vela strays offside. Barca's marking was uncharacteristically questionable there, though.
48 minCastro shows off his pace in the final third but Pedro does just enough to put him off as he swings in his cross. Griezmann was waiting there in the box but the ball doesn't reach him.
50 minA positive start from Sociedad in the second half. They have set their stall out well are the ones doing all the pressing at the moment. Barca looking a little unsettled right now.
51 minSHOT! Sociedad claim the first effort on goal of the second period, but it's poor. Vela lets fly from the edge of the box after finding himself in space, but he blazes it over the bar. He should have tested the goalkeeper there!
54 minBarca claim the first corner of the second half as Asier Illarramendi scrambled the ball behind. They haven't had it as comfortable as usual tonight, though. Sociedad are looking the more likely to claim the next goal.
56 minRED CARD! Gerard Piqué is given his marching orders for a second yellow card offence, this one a foul. He'll be kicking himself for that needless booking for dissent in the first half!
58 minBOOKING! Tempers are boiling over now as Iniesta commits a foul right on the edge of the box. Barca are really under the cosh now and are struggling to deal with what the hosts are throwing at them. We could have a surprise on our hands tonight!
59 minSUBSTITUTION: The league leaders throw on Javier Mascherano to replace Fábregas in a bid to steady the ship. They are still reeling from that Piqué sending off.
64 minWe are level! Sociedad just kept banging on that door until they broke it down. Griezmann and Vela had efforts on goal moments before Castro's effort from wide cannoned off Mascherano and into the net!
65 minI think that has officially gone down as a Mascherano own goal, but Castro deserves all of the credit. His thunderous effort may have taken a vicious deflection on its way in, but I think Valdes would have had a job on his hands keeping that one out regardless.
67 minBarca in real danger of dropping points in La Liga for only the second time this season. In fact, they could even be facing their first defeat if things continue at this rate.
70 minSome scrappy play from Sociedad as Antoine Griezmann and Alberto De la Bella commit fouls just minutes apart. The latter's offence was deep in the Barca half, so Sergio Busquets plays it upfield from the defensive free kick.
73 minBOOKING! Busquets is shown the yellow card for a two-footed tackle. He may have won the ball, but that still counts as dangerous play.
74 minSUBSTITUTION: Sociedad make an attacking change, bringing on Uruguayan striker Diego Ifran for Castro, who goes off to a great reception.
77 minBarca apply some pressure of their own, winning a corner through Messi. The Argentine takes it himself but it goes begging. I think Tito Vilanova will just be relieved to see his side off the back foot. They have been second best throughout this half.
79 minSociedad's Asier Illarramendi is shown a justified yellow card for a bad tackle and the hosts make a change moments later, throwing on Rubén Pardo replaces Xabi Prieto. That one was a defensive change. I was thinking the hosts would be going all-out to win this!
82 minEight minutes remaining on the clock now and there is a tense atmosphere around the ground, as though a single mistake could cost either side the game. Clear-cut chances have been few and far between since the equaliser, though.
84 minSUBSTITUTION:, Real Sociedad bring on Imanol Agirretxe to replace Carlos Vela. A straight switch up-front for the hosts. Could this pair of fresh legs help them snatch a winner?
86 minDani Alves fouls Asier Illarramendi and gives away a free kick on the left wing, but Sociedad fail to create anything from the set piece.
89 minSUBSTITUTION: Barcelona bring on Adriano in place of Pedro. The Brazilian has been amongst the goals of late. Can he snatch a winner here?
90+1 minGOAL! Real Sociedad 3-2 Barcelona (Agirretxe)
90+1 minOh my word! Sociedad appear to have snatched it in stoppage time through substitute Agirretxe! Carlos Martínez played a deft cross in behind the Bara defence and Agirretxe toe-poked one past a stranded Valdes!
6.50pmThere you have it, Barcelona's first defeat of the season and Real Soceidad very much deserved it. Barca will be kicking themselves for allowing a two-goal advantage to slip, but let's take nothing away from a spirited Sociedad.