MADRID (AP) – Real Sociedad ended Real Madrid's 21-game unbeaten run by winning 4-3 at the Santiago Bernabeu on Thursday to reach the Copa del Rey semifinals for the first time in six years.
The result halted Madrid's eight-game winning streak and handed the club its first loss in all competitions since October.
It also ended Madrid's hopes of winning the cup competition for the first time since 2014.
Real Sociedad, a semifinalist in 2014, will be looking to win its third Copa del Rey trophy - and first since 1987.
''Our fans deserved a prize like this,'' Sociedad coach Imano Alguacil said. ''This victory means a lot, coming at a packed Bernabeu, against a team like Real Madrid, with our team playing well. You can imagine how we are feeling right now.''
The visitors looked in control for most of the match but Madrid came close to pulling off the comeback after scoring late goals in the second half.
''We gave everything we had in the end, but it was too late,'' Madrid defender Marcelo said. ''It's hard to come back after conceding four goals at home. It's disappointing, but we still have other competitions ahead of us.''
Madrid had been dominant thanks in part to a stout defense, having conceded only 13 goals in 22 Spanish league matches.
Young Norwegian playmaker Martin Odegaard, playing for Sociedad on a loan from Madrid, didn't celebrate after opening the scoring in the 22nd minute off the rebound of a save by Madrid goalkeeper Alphonse Areola.
Young Swedish striker Alexander Isak added to the lead with goals two minutes apart early in the second half - a volley in the 54th and a shot into the top corner in the 56th.
The 20-year-old Isak had already had a goal disallowed for offside after video review just minutes after the break.
Marcelo pulled Madrid closer with a low shot from inside the area in the 59th, but Mikel Merino increased the visitors' lead again from close range in the 69th.
Rodrygo netted Madrid's second in the 81st, two minutes after Vinicius Junior had a goal disallowed by video review. The third came through a header by Nacho Ramos three minutes into stoppage time.
Sociedad defender Andoni Gorosabel was sent off just before the final whistle.
The Copa is being played in single-elimination games this season, except in the semifinals.
Granada eliminated defending champion Valencia on Tuesday, while second-division club Mirandes got past Villarreal on Wednesday. Barcelona visited Athletic Bilbao later Thursday.
Mirandes will be the only lower-division team in the semifinals.