Third-tier Alcorcon lost 1-0 to Real Madrid at the Bernabeu on Tuesday but dumped the nine-times European champions out of the King's Cup 4-1 on aggregate.
Real had promised to rectify their embarrassing 4-0 first leg defeat at Alcorcon with a stirring fightback at home at the last-32 stage.
Manuel Pellegrini's side though, boasting Raul and Ruud van Nistelrooy up front supported by Gonzalo Higuain and Kaka, created little in front of a near-full house.
Alcorcon operate on a budget of just over one million euros ($1.50 million), some 400 times smaller than Real's.
"Beating Real Madrid is a dream come true and there is a nice party going on right now in the dressing room. I think we deserve it," Alcorcon coach Juan Antonio Anquela said.
"The players made an incredible effort and I want to thank them publicly for that."
The visitors were disciplined and organised and grew in confidence the longer Real laboured.
The hosts threatened briefly at the start of the second half, when they hit the crossbar, and as the chances dried up disgruntled fans started whistling the players and chanting for Pellegrini to go.
Real substitute Rafael van der Vaart scored from outside the area with nine minutes left and Higuain hit the bar but by then fans were streaming out of the Bernabeu.
The supporters that remained cheered Alcorcon's every touch towards the end and gave them a standing ovation at the finish.
"We can't say we didn't try but it's clear we didn't achieve our objective," Real director general Jorge Valdano told Canal Plus television. "But I say again we have absolute confidence in the coach, the same as we did before the game."
It is the second year in a row Real have been humbled by a Segunda B side in the Cup after Real Union beat them at the same stage last season.
PENALTIES
The only other top-flight sides to lose to lower league opposition were Tenerife, who fell 3-1 on aggregate to second division Celta Vigo, and Sporting Gijon who lost a penalty shootout against second division Recreativo Huelva.
Atletico Madrid and Sevilla swept aside their Segunda B opponents to progress.
Argentina midfielder Maxi Rodriguez netted four as Atletico completed an aggregate 8-0 rout of Marbella, and Sevilla substitute Jose Carlos bagged two as they beat Atletico Ciudad 9-3 on aggregate.
Ten-man Valencia hung on to draw 2-2 at home against Segunda B side Alcoyano to go through 3-2 overall, and Villarreal edged past another third-tier side Puertollano 2-1 on aggregate thanks to a late goal from Italy striker Giuseppe Rossi.
Deportivo Coruna, Malaga and Osasuna also made the last 16.
All eyes on Pellegrini's future at Real Madrid
Nervy Real ride on Raul brace, Sevilla lose
I hope Ronaldo recovers after Madrid derby: Simao
Depleted Real Madrid held by Sporting Gijon
Real, Portugal clash over injured Ronaldo