Former Madrid winger Takefusa Kubo and Ander Barrenetxea netted the goals for Real Sociedad against Los Blancos, tightening their grip on fourth spot and Champions League qualification.
Madrid defender Dani Carvajal was sent off after an hour for a second yellow card to make matters worse for Los Blancos, who face Osasuna in the Copa del Rey final on Saturday.
“It’s not the best way to prepare for games,” said Madrid coach Carlo Ancelotti.
“A defeat always hurts, it lowers your dynamic, the good feelings, so it’s not the best way to prepare for what’s to come.
“In the players’ heads obviously is more, the Copa final, the Champions League semi-finals, that has an effect.
“When you don’t have good concentration, you end up giving away gifts.”
The Italian played a makeshift side because of injuries and suspensions, and he also left striker Karim Benzema behind in the Madrid capital ahead of Saturday’s cup finale.
Kubo struck at the start of the second half for the hosts after Eder Militao gave the ball away in a dangerous area.
Carvajal was dismissed for a foul on Real Sociedad forward Mikel Oyarzabal, giving Madrid an uphill struggle.
Madrid goalkeeper Thibaut Courtois did well to parry a deflected Barrenetxea strike, but he could not keep out the forward’s next effort, surprising the Belgian at his near post.
If third place Atletico Madrid beat Cadiz on Wednesday, they can move second.
Real Sociedad are eight points clear of fifth-place Villarreal, who have played one fewer game.
Bottom-of-the-table Elche were relegated after a 2-1 defeat at Almeria. Source: Sports Brief