Real Sociedad shocked Real Madrid 4-3 on Thursday in the 2020 Copa del Rey quarter-finals at the Santiago Bernabeu Stadium.
Martin Odegaard opened the scoring for Sociedad against his parent club after 22 minutes, giving the away side a half-time advantage.
Alexander Isak bagged two goals in two minutes after initially striking in the 54th minute, before Marcelo pulled one back for Los Blancos after 59 minutes.
Mikel Merino completed an amazing night for the visitors with their fourth after 69 minutes, but Madrid continued to battle until the end.
Rodrygo grabbed a second goal for Madrid with nine minutes remaining as they chased the game, and Nacho made it 4-3 in the third minute of stoppage time.
The defeat is Los Blancos' first since October after a 21-game unbeaten streak in all competitions.
Madrid fielded a strong starting XI captained by Sergio Ramos and featuring Toni Kroos, James Rodriguez and Karim Benzema. The result which was to follow couldn't have been predicted at the first whistle.
Odegaard was a pre-match focus for the press and supporters on his return to the capital, and the 21-year-old didn't disappoint after opening the scoring.
The midfielder refused to celebrate his first-half effort after rebounding home the ball from Isak's shot, which was parried by Madrid goalkeeper Alphonse Areola.
The goal action followed in the second half when Sociedad put distance between themselves and the La Liga leaders.
Isak was always a threat, and the Sweden international scored a quick-fire brace to stun the home crowd. The 20-year-old had a goal ruled out by VAR for offside after the restart, but an outrageous volley from the forward was immediately followed by a calm finish, and Sociedad were suddenly 3-0 up.
Madrid dominated possession for long spells, and Zinedine Zidane's men finally added to the scoresheet as the clock ticked down when Marcelo made it 3-1. The full-back converted at the near post, but Isak's influence remained key, as the attacker assisted for the visitors' fourth moments later.
Merino made it 4-1, and Sociedad appeared home and dry, but the drama continued as Madrid attempted to turn the tide.
Luka Jovic came off the bench as Zidane primed his attack, and the decision almost saved the day for Los Blancos.
Vinicius Jr. set up Rodrygo for an easy finish in the final stages of the contest, and Nacho headed home Benzema's excellent cross during injury time to make it 4-3.
Sociedad's Andoni Gorosabel was given his marching orders for a second yellow in the fifth minute of stoppage time. Ramos' last-gasp header was then saved by Alex Remiro, denying Madrid the chance to level at the death.
Both clubs are back in La Liga action on Sunday. Madrid travel to Osasuna, and Sociedad welcome Athletic Bilbao. The Copa semi-final draw takes place at 12 p.m. GMT/7 a.m. ET on Friday.