Marcelo and Rodrygo both scored late in the second half and while Mikel Merino also added a fourth for the visitors, a Nacho Fernandez header set up a pulsating final three minutes, in which Andoni Gorosabel was also sent off.
Ten-man Real Sociedad held on for a sensational win to progress to the last four while Madrid’s run without success in Spain’s domestic cup extends to six years.
On loan at Sociedad, the plan was for Odegaard to stay one more year at Anoeta but this glittering display, that earned him a standing ovation from the home fans when he went off, may well persuade Madrid to recall him early.
Their 21-game unbeaten streak comes to an end after an uncharacteristically careless performance in which a rotated side highlighted the importance of the likes of Casemiro, Raphael Varane and Thibaut Courtois.
Courtois’ replacement Alphonse Areola was at fault for at least one of the goals while Marcelo was typically unpredictable at left-back, a position the more dependable Ferland Mendy has made his own in recent weeks.
Yet Zinedine Zidane’s changes should take nothing away from Real Sociedad, who showed why they were pushing for a place in La Liga’s top four earlier this season, before a dip in form has seen them slip to eighth.
There were early warnings as Isak sped in behind but his shot was blocked by the diving Eder Militao and from the resulting corner, the Swede was picked out with a driven cross only to skew his finish.
Isak was involved in the opener too after 22 minutes, as his effort was saved by Areola, who then failed to readjust in time to prevent Odegaard firing through his legs.
Ander Barrenetxea had only come on at half-time but nine minutes into the second half, he had set up a second.
It was the first of two goals in as many minutes as the 18-year-old’s floated cross was met brilliantly by the acrobatic Isak, who then made it three shortly after, rifling in at the near post after the ball had deflected to his feet.