Real Madrid crashed out of the Copa del Rey as Leganes pulled off a shock 2-1 victory to reach the semi-finals for the first time ever.
Sergio Ramos made his comeback in the heart of Madrid's defence, but Zinedine Zidane nonetheless named a second-string XI, with Marcelo, Toni Kroos, Gareth Bale and Cristiano Ronaldo all absent.
Leganes, meanwhile, had lost all three of their previous meetings with Los Blancos, but they took a deserved lead on the half-hour mark, when Javi Eraso pickpocketed Nacho Fernandez near his own box and curled an unstoppable strike past Kiko Casilla.
Karim Benzema equalised for Madrid just two minutes into the second half, dinking an acute finish over Nereo Champagne for his first goal since early December, but Gabriel's bullet header from a corner won Leganes the tie.
Los Merengues had enough chances to go through themselves, but Champagne was on top form to tip over a pair of headers and push away Benzema's close-range finish.
Asier Garitano's troops will face either Sevilla, Alaves or one of Barcelona and Espanyol in the last four.
Real Madrid 1-2 Leganes (2-2 agg.)
Benzema 47 (RM) Eraso 31, Gabriel 55 (L)
Real Madrid: Casilla; Achraf (Carvajal 68), Vallejo, Ramos, Theo; Kovacic, Marcos Llorente (Modric 69), Isco (Mayoral 77); Vazquez, Benzema, Asensio
Leganes: Champagne; Tito, Bustinza, Siovas (Mantovani 58), Diego Rico; Brasanac, Gabriel; El Zhar (Naranjo 80), Eraso, Amrabat (Raul Garcia 70); Beauvue
Referee: Gil Manzano