Real Sociedad ended Real Madrid's 21-game unbeaten run by winning 4-3 at the Bernabeu on Thursday to reach the Copa del Rey semifinals for the first time in six years.
Sociedad's Sweden forward Alexander Isak inspired an incredible attacking display, scoring twice in the second half to put the Basque side 3-0 up after Martin Odegaard, who is on loan from Madrid, had given the visitors a first-half lead.
Madrid defender Marcelo quickly pulled a goal back to make it 3-1, moments after receiving a volley of boos from the home fans, but Sociedad soon restored a three-goal cushion when Isak teed up Mikel Merino for a simple tap-in.
Madrid substitute Rodrygo scored to cut the lead to 4-2 after his Brazilian teammate Vinicius Junior had a strike ruled out for offside following a VAR review, while Nacho struck in added time for the hosts, setting up a tense finish.
Sociedad defender Andoni Gorosabel was sent off in stoppage time, but Madrid could not find an equaliser and suffered their first defeat in any competition since losing 1-0 at Real Mallorca on Oct. 19.
"It's a bad feeling because we lost at home. We started badly. We tried until the end and the second half was much better. Even at 4-1 we tried we fought," Real Madrid manager Zinedine Zidane. "The opponent played well. We were bad in the first half with our press, then we made defensive mistakes.
On the squad rotations, Zidane said: "When I pick a team I think it's a team that can do well. It's easy to have an opinion afterwards. I don't think we made a mistake with the team. It's true that the opponent did well, they scored first, and we made mistakes. But it's nothing to do with the line-up or the team."
"Today we let in four goals at home and it's difficult to come back from that. We tried very hard to pull it off, but we reacted a little too late," Marcelo told reporters. "Real Madrid is a very demanding club, and when you don't win it's difficult, but we are still in two competitions, we have a very big squad with top players."
Madrid host Manchester City in the first leg of their Champions League last 16 tie on Feb. 26.
Information from ESPN's Alex Kirkland and Reuters was used in this report.