Barca had previously dropped just two points all season and looked set to extend their remarkable record to 19 wins out of 20 as they opened up a two-goal lead, only to be stunned by a Sociedad fightback.
Lionel Messi opened the scoring when he latched onto Andres Iniesta's pass and cut in to slot a left-footed shot low past Sociedad goalkeeper Claudio Bravo from the edge of the penalty area.
Pedro added a second on 25 minutes with a finish from close range after Xavi dinked the ball over the top for Dani Alves to cross.
However, Gonzalo Castro halved Sociedad's deficit before the interval with a brilliant strike and Barca were reduced to ten men in the 56th minute as Gerard Pique was sent off for a second bookable offence.
Castro's curling effort was then deflected into his own net by Barca substitute Javier Mascherano to make it 2-2, and Imanol Agirretxe poked Carlos Martinez's cross from the right past Victor Valdes in the 90th minute to send the home fans wild and Barca in shock.
In the first game of the day, Granada secured only their second home win of the season as they beat Rayo Vallecano 2-0.
The visitors came into the game on the back of four consecutive wins that had propelled them into the European places, but were made to pay for some defensive mistakes.
A Jordi Amat own goal gave Granada the lead on 25 minutes as he inadvertently turned Allan Nyom's cross beyond goalkeeper Ruben.
Recio secured victory ten minutes from time with a fine arrowed drive from Carlos Aranda's cut-back, boosting Granada's hopes of beating the drop.
Sevilla failed to get Unai Emery's league reign off to the perfect start as an error from goalkeeper Andres Palop gifted Getafe a 1-1 draw at the Alfonso Perez Coliseum.
Jose Antonio Reyes put Sevilla in front with a neat finish shortly before half-time, but the lead lasted only three minutes as Palop got caught under Adrian Colunga's inswinging cross and allowed the ball to float over his head and into the net.
Malaga failed to significantly boost their Champions League hopes after being held to a 1-1 draw at home by lowly Celta Vigo.
Former Bayern Munich player Martin Demichelis had given Malaga a 38th minute lead, but Celta earned a point through Augusto Fernandez's 76th minute equaliser.