Barcelona lost for the first time this season as quickfire goals from Nabil El Zhar and Oscar Rodriguez saw Leganes move off the foot of the LaLiga table with a famous 2-1 victory.
Leganes had taken only one point from their opening five matches and would have sensed a fruitless night lay ahead when the defending champions took a 12th-minute lead through Philippe Coutinho.
However, a Barca line-up also containing Lionel Messi, Ousmane Dembele, Ivan Rakitic and Gerard Pique were stunned as El Zhar drew the hosts level before Oscar struck almost immediately afterwards.
Barca, who had scored eight times in their previous two trips to the Estadio Municipal de Butarque, predictably threw everything forward in search of a leveller to no avail.
They had dropped points for the first time in this campaign following a pulsating 2-2 draw at home to Girona on Sunday but this is a chastening defeat compounded by Real Madrid loanee Oscar bagging the clincher.
Luis Suarez was benched with Munir El Haddadi handed his first start of the season, but the Catalan giants still put out a strong line-up.
Barca, playing in their yellow away kit, were on the front foot from the off and Dembele fired into the side-netting early on.
Their pressure was rewarded as Coutinho opened the scoring in spectacular fashion, teeing himself up to rifle a low volley from outside the area that left Leganes goalkeeper Ivan Cuellar with little chance.
Messi was only denied from adding to Barca’s lead by the goal frame, with his curling effort beating Cuellar but cannoning back off the crossbar.
However, Leganes slowly grew into the half and only the intervention of goalkeeper Marc-Andre ter Stegen prevented Juanfran’s free-kick and Oscar’s curler from levelling proceedings.
There was nothing Barca’s number one could do as Leganes equalised six minutes into the second half, with Morocco’s former Liverpool winger El Zhar heading home from Jonathan Silva’s left-wing cross.
And Oscar then profited from a huge Pique mistake to give Leganes a surprise lead.
There looked to be little danger when Pique raced to prevent Silva from latching on to a long ball forward but the Barca centre-back’s pass sideways picked out Oscar, who gratefully fired high into the net.
Ernesto Valverde introduced Suarez soon after but an off-colour Barca seemed shell-shocked by the double strike.
Cuellar did his bit to preserve Leganes’ lead with an impressive brace of saves, first keeping out Coutinho’s free-kick and then denying Rakitic with the follow-up.
Barca grew increasingly more desperate as time ticked away, sending up Ter Stegen for a corner in the dying seconds, but Leganes held firm for a win that will go down as one of the greatest in their history.
Defeat was only Barca’s second in LaLiga under Valverde in 43 matches.