Before Wednesday, the Copa del Rey and Champions League were the best hopes of silverware left for the team and, after finding a late winner at the Estadio Municipal de Butarque through Marco Asensio, Madrid would have been confident in advancing to the semi-finals against a team that struggled against relegation last season.
After all, Los Blancos had never once in their history failed to defend a first-leg Copa lead at their home ground and Leganes, though much improved this campaign, are still a bottom-half team in La Liga.
Javier Eraso's goal just after the half-hour mark put the home side on notice, as Madrid failed to register a shot on target in the first half for just the second time this season.
But Karim Benzema's equalizer just after the break had Madrid looking like favourites once more.
Then came the stunner, with Gabriel putting the visiting side back in front just seven minutes later, and Madrid would never recover.
The loss is a brutal blow for Madrid, who face the daunting task of Neymar, Edinson Cavani and Paris Saint-Germain in the Champions League round of 16, with Europe's top prize the only realistic chance for silverware remaining in what has become an unfathomably disappointing season.
1 - Leganes are the first team in Copa del Rey history to knock out Real Madrid at Santiago Bernabeu after losing at home in the first leg. Correction. pic.twitter.com/tO51r3r4HK— OptaJose (@OptaJose) January 24, 2018
Madrid will face three league matches against Valencia, Levante and Real Sociedad, before they get their first crack at PSG on Feb. 14, but Zidane's side will have to find some way to get the ship righted to have any real hope of moving past the French giants.
For Leganes, the win over Madrid is one for the history books for another reason as well, with the club securing a first trip to the Copa del Rey semi-finals.