La Liga Wrap: Disjointed Real beaten, Barca win
It appeared European champions Real Madrid would emphatically put worries over a poor start to the season behind them when they flew out of the blocks, Gareth Bale's neat finish adding to Sergio Ramos' header to secure a 2-0 lead after 11 minutes.
But they missed a series of other chances during a dominant start and were made to pay the price as Inigo Martinez pulled a goal back.
Suddenly full of confidence, Sociedad took control thereafter, David Zurutuza's double added to by Carlos Vela to secure an incredible triumph.
It left Real Madrid on three points through two league games, while the win was Sociedad's first of the campaign.
Debutant Sandro was the unlikely hero as Barcelona left it late to snatch a 1-0 victory at Villarreal and be the only team in the league with a perfect record.
Barca toiled on a poor El Madrigal pitch and against a stubborn home defence until 19-year-old Sandro came off the bench to score a scrappy 82nd-minute winner in his first La Liga appearance.
A goal-fest was played out at Estadio Riazor, where Deportivo La Coruna and the visiting Rayo Vallecano drew 2-2 thanks to Isaac Cuenca's last-gasp penalty for the hosts.
Jose Rodriguez fired Deportivo into a seventh-minute lead, yet they were pegged back as Alberto Bueno headed home an equaliser before producing a close-range 73rd-minute goal to put his side in front.
It appeared his efforts would prove decisive until Abdoulaye Ba handled in the area, paving the way for Cuenca to secure a share of the spoils.
David Lomban scored a dramatic late equaliser to see Elche play out a 1-1 draw at home to Granada.