Barca beaten for first time away at Sociedad
Imanol Agirretxe stunned the visitors by sliding in to grab a last-gasp winner after a double from Gonzalo Castro, who scored either side of half-time, helped cancel out early goals for the visitors from Lionel Messi and Pedro.
A full-strength Barca had dominated the first half, but Pique's second yellow card in the 56th minute came when Sociedad were in the ascendancy, and the hosts were eventually rewarded for their endeavour in time added on.
Barca, who had won every league game except for a 2-2 draw at home to champions Real Madrid in October, stayed on 55 points from 20 games.
"I have to congratulate Real Sociedad. Their victory is more to do with how well they played than my players not playing well," Barca coach Tito Vilanova told a news conference.
In the late game, Malaga goalkeeper Willy Caballero saved a point for his side by denying Enrique De Lucas in a one-on-one in the last minute as they held on for a 1-1 draw at home to Celta Vigo.
Malaga defender Martin Demichelis gave Manuel Pellegrini's side the lead after 31 minutes when he got the final touch to the ball after a goalmouth scramble.
But Celta's Augusto Fernandez pounced on a loose ball to fire home the equaliser in the 76th and leave Malaga fifth with 32 points.
Rayo Vallecano's impressive surge up the table was halted when they lost 2-0 at Granada and missed a chance to consolidate their position in the European qualifying places.
Granada took the lead when Rayo defender Jordi Amat turned the ball into his own net under pressure from Odion Ighalo in the 24th, and Recio completed only their second home win of the campaign with a low shot 10 minutes from time.
Rayo stayed sixth with 31 points, while Sociedad's victory left them ninth with 29.
Getafe are 10th with 26 points after a 1-1 home draw with Sevilla on Unai Emery's league debut at the helm for the Andalusians.
Barcelona's World Player of the Year Messi had already fired wide in a one-on-one with the keeper when he stroked in his 29th league goal this season from the edge of the area in the seventh minute at Anoeta.
Messi has now scored in 10 consecutive league games to match the La Liga record set by fellow Barca players Mariano Martin in the 1942/43 campaign and Brazil's Ronaldo in 1996/97.
Pedro lashed a shot against the post and in the 18th minute the referee had to stop the match and ask both captains if they were happy to continue after a partial floodlight failure.
The game resumed and Dani Alves crossed low for Pedro to slide in and notch Barca's second in the 25th before a Messi lob bounced against the post and was cleared from the goalmouth.
"The key moment was when Messi's shot stayed on the line. At 3-0 it would have been game over," Vilanova added.