(Adds details, quotes)
MADRID, Feb 6 (Reuters) - Real Madrid were dumped out of the Copa del Rey at the quarter-final stage on Thursday after losing 4-3 at home to Real Sociedad in a hugely entertaining game which saw two goals ruled out by video technology and a late red card for the visitors.
Sociedad's Sweden forward Alexander Isak inspired an incredible attacking display, scoring twice in the second period, setting up the fourth goal for Mikel Merino and also having a strike ruled out for offside.
Norwegian midfielder Martin Odegaard, who is on loan from Madrid, had given the visitors the lead midway through the first half, following up on the rebound after home keeper Alphonse Areola could only parry a long-range effort from Isak.
Defender Marcelo quickly pulled a goal back for the hosts after Isak's quick-fire brace to make it 3-1, beating keeper Alex Remiro at the near post moments after receiving a volley of boos from the home fans for his haphazard display.
But rampant Sociedad soon restored a three-goal cushion when Isak teed up Merino for a simple tap-in after 69 minutes.
Madrid substitute Rodrygo pulled a goal back in the 81st to make it 4-2 after his Brazilian team mate Vinicius Jr had a strike ruled out for offside following a VAR review, while Nacho struck in added time for the hosts to set up a tense finish.
Sociedad defender Andoni Gorosabel was sent off in stoppage time but Madrid, who are top of La Liga, could not find an equaliser and suffered their first defeat in any competition since losing 1-0 at Real Mallorca on Oct. 19.
"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. (Reporting by Richard Martin in Barcelona; editing by Ken Ferris)