Barcelona lost for the first time this season after bottom-of-the-table Leganes came from behind to pull off a sensational victory.
Philippe Coutinho had put Barca in front with a 20-yard volley but Nabil el Zhar and Oscar Rodriguez scored twice in just 68 seconds.
Barca boss Ernesto Valverde lost for just the second time in La Liga since taking charge in the summer of 2017.
Leganes had just one point from five games going into the match.
But they stunned their illustrious opponents after the break, with Gerard Pique at fault for their second goal.
The defender inadvertently passed to Oscar, who is on loan from Real Madrid and slotted home the winner from 12 yards.
Barca had looked comfortable at 1-0, with Lionel Messi hitting the woodwork but they were shell-shocked by the two quick-fire goals.
The visitors never really looked like equalising, except for one brief spell when Ivan Cuellar’s double save denied Philippe Coutinho’s curler and Ivan Rakitic’s follow-up.
Barcelona stay top of the table after Real Madrid lost 3-0 to Sevilla later on Wednesday – the first time both sides have lost a La Liga game on the same day since 2015.
“It’s not a result that can be explained,” said Valverde – whose side won the domestic double last season. “We found it hard to create chances, and they shut up shop at the back.
“It’s not an easy moment. We weren’t expecting this. But we have another important game on Saturday [against Athletic Bilbao] in front of our fans. We have to pick ourselves up and we’ll need everyone’s help to do that.”
Leganes, meanwhile, climb to 17th in the table with their first victory of the season.