Real Madrid were stunned by La Liga’s bottom club Rayo Vallecano, who kept their slim hopes of survival alive.
It is the first time Real have lost to a team bottom of the league since 2004.
Boss Zinedine Zidane made eight changes to his team as he continues to experiment with his third-placed squad, who have little to play for.
Adrian Embarba scored the only goal for Rayo from a video assistant referee-awarded penalty following a Jesus Vallejo foul on Javi Guerra.
The referee did not initially award a penalty. Real broke and Gareth Bale had a shot saved before the referee viewed the incident on a screen and gave a spot-kick.
Had Bale scored, it would have been disallowed.
Embarba sent Thibaut Courtois, playing for the first time under Zidane, the wrong way in what proved to be the winner.
He is now Rayo’s joint second top scorer this season with four goals. Their main goalscorer Raul de Tomas was ineligible because he is on loan from Real.
Madrid minnows Vallecano – who had only won one of their previous 13 games – are six points adrift of safety with three games to go.
Real Madrid have now lost 10 La Liga matches this season – their most in a campaign since 2008-09, when they also lost 10. They have lost in 16 games in all competitions – also level with 2008-09.
This is the first time they have failed to score in consecutive games under Zidane, including his previous two-and-a-half-year spell in charge. They drew 0-0 at Getafe, in another Madrid derby, on Thursday.
Karim Benzema, who missed this game with an injury, was their only goalscorer in the whole of April. He has netted their most recent eight goals.