Barcelona entered the match knowing that a victory would have moved them three points clear of second-placed Atletico Madrid at the top of the La Liga table ahead of next weekend's showdown between the top two.
However, Leganes took a shock lead early on, with Gonzalez heading a corner from Oscar Rodriguez into the back of the net - the opener came just 195 seconds into the match, making it the earliest goal conceded by Barcelona this season.
Hansi Flick's side had 80% of the possession and managed 20 attempts on the night, but just four of their efforts were on target, and an incredible defensive performance from Leganes saw them hold on for their first-ever away victory over Barcelona.
The defeat is huge news for Atletico and Real Madrid in the terms of their title ambitions this season, while Leganes have now moved onto 18 points in the division, which has left them four points ahead of the bottom three.
SPORTS MOLE'S VERDICT
It was supposed to be a routine home success for Barcelona, and it looked a very tough night for Leganes on paper considering that Raphinha, Dani Olmo, Lamine Yamal and Robert Lewandowski started as the front four.
Barcelona just could not find a route past Leganes goalkeeper Marko Dmitrovic, though, with the 32-year-old making three excellent saves, and even Ferran Torres, who has been in fine form of late, could not make a difference off the bench.
Real Madrid dropped points on Saturday, drawing 3-3 with Rayo Vallecano, but Atletico are in sensational form, winning each of their last 11 matches in all competitions, including a 1-0 success over Getafe in La Liga on Saturday.
Atletico are now level on points with Barcelona with a game in hand, and the two sides will meet for a blockbuster contest next weekend.
Barcelona have now been beaten on four occasions in La Liga this term, with three of those coming in their last six matches, and it is set to be an incredibly open title race in La Liga this season, as the two giants of Spanish football are both having their problems.
Atletico boss Diego Simeone will surely be growing in confidence in terms of a title challenge this term.
BARCELONA VS. LEGANES HIGHLIGHTS
4th min: Barcelona 0-1 Leganes (Sergio Gonzalez)
Leganes take a shock lead in the fourth minute of the contest, as Gonzalez heads a corner from Rodriguez into the back of the net; the defender was allowed to rise inside the penalty box and made no mistake to silence the home fans.
MAN OF THE MATCH - SERGIO GONZALEZ
Gonzalez will take the headlines courtesy of his winning goal against the division leaders, and it was a brilliant header, but it is the 32-year-old's overall performance that earns him the man-of-the-match award here.
The centre-back was a towering presence for Leganes, with Lewandowski struggling to get the better of the experienced defender, and there is no question that he will remember this match as one of the standout moments of his career.
BARCELONA VS, LEGANES MATCH STATS
Possession: Barcelona 80%-20% Leganes
Shots: Barcelona 20-6 Leganes
Shots on target: Barcelona 4-4 Leganes
Corners: Barcelona 8-2 Leganes
Fouls: Barcelona 5-13 Leganes
BEST STATS
WHAT NEXT?
Barcelona, as mentioned, have a huge game against Atletico at Estadi Olimpic Lluis Companys next Saturday, and Simeone's side will bring an 11-match winning run into what is shaping up to be a fascinating contest.
Leganes, meanwhile, will be bidding to build on their sensational result when they welcome Villarreal next Saturday.
Written by
Matt Law