A mistake by Barca's usually excellent goalkeeper Marc-Andre ter Stegen gave the home team an equalising goal that sealed the match.
Barcelona gave Real Madrid the chance to go top of La Liga ahead of Wednesday's Clasico at Camp Nou as they were held to a 2-2 draw by high-flying Real Sociedad on Saturday.
A mistake by Barca's usually excellent goalkeeper Marc-Andre ter Stegen gifted the home side an equaliser in a thrilling contest at Anoeta between two of the division's most attacking teams.
Antoine Griezmann and Luis Suarez looked to have turned the game around after Mikel Oyarzabal scored an early penalty but Real Sociedad claimed a deserved point as Ter Stegen parried into the path of Alexander Isak.
Madrid will pull two points clear at the top of the table if they win away at in-form Valencia on Sunday, which could prove a significant psychological boost ahead of their crunch meeting with Barcelona in midweek.
"Wednesday's game will be different," said Barca coach Ernesto Valverde. "The game has a special meaning but there are some things we need to improve."
Atletico Madrid have work to do to rejoin the title chase but they capitalised on Barca's slip a few hours later by beating Osasuna 2-0.
Real Sociedad, meanwhile, move to within three points of Sevilla in third and showed why many have them circled as genuine challengers for Champions League qualification this season.
Barca may have had one eye on their next encounter, particularly given renewed fears of unrest around the Clasico, which had to be postponed in October due to Catalan independence protests.
Two tight penalty calls also went Real Sociedad's way as they got one for a shirt-pull by Sergio Busquets and got with away another as Gerard Pique went down at the back post late on.
"If you set the bar so low for the first penalty, you have to give the others," said Busquets.
"The foul on Pique was clear. I think the referee saw it but he didn't want to whistle."
Yet Real Sociedad were excellent value for their point, with Martin Odegaard, the Norwegian playmaker on loan from Real Madrid, delivering a majestic display to help his parent club's title bid.
"Now he is playing regularly you can see what a player he is," Valverde said.
Barcelona were on the ropes for much of the first half an hour as their opponents moved the ball quickly through the lines, with Odegaard the orchestrator.
Odegaard gave Busquets a torrid time and too often Barca were opened up through the middle. On one occasion, Nacho Monreal might have shot but chose to cross, forcing Gerard Pique into a last-ditch clearance.
The home goal though came from a corner as Busquets was spotted tugging Diego Llorente's shirt.
The offence seemed minor but referee Javier Alberola had a clear view. Oyarzabal made no mistake from the spot.
Barcelona were yet to create a genuine chance but in the 38th minute they were level as Suarez freed Griezmann, who drew the goalkeeper before scooping his finish brilliantly into the net. Griezmann chose not to celebrate against his former club.
The visitors improved after half-time and were ahead within four minutes of the restart. Busquets clipped a ball over the top of Llorente, who stepped up at the wrong time, allowing Lionel Messi to skip free.
He generously sidefooted left to Suarez, who had an open goal.
Pique almost made it 3-1 but his header was cleared off the line by Mikel Merino.
Instead Real Sociedad levelled. Monreal's cross caused panic and Ter Stegen parried the ball straight to Isak, who had a simple finish five yards out.
Atletico reduced the gap behind Barcelona to six points, albeit having played a game more, after they scored twice in the second half to beat Osasuna.
Diego Simeone's side had managed only one goal in their previous three league matches and looked set for another night of frustration when the score was goalless after an hour at the Wanda Metropolitano.
But Alvaro Morata headed in Kieran Trippier's crossed free-kick in the 67th minute and Saul Niguez added a second eight minutes later, finishing off a neat move on the edge of the area involving Morata and Angel Correa.