Gerard Moreno struck deep in stoppage-time to give Espanyol a dramatic 1-0 win over Real Madrid at RCDE Stadium.
A much-changed Real Madrid, with Cristiano Ronaldo left out of the squad, looked to have done enough to labour to a share of the points.
However, with more than two minutes of added time played, Espanyol broke clear and Moreno crashed the ball past Keylor Navas to give the Barcelona club a first win over Real Madrid since 2007.
Los Blancos were looking to build on a seven-match unbeaten run
in LaLiga, which had seen them pick up six victories and score 30 goals.
Head coach Zinedine Zidane opted to make five changes from Sunday’s 4-0 home win over Alaves, with captain Sergio Ramos back from suspension.
Gareth Bale retained his place, and the Wales forward almost opened the scoring on seven minutes.
However, his close-range header flew straight at Espanyol keeper Diego Lopez after right-back Achraf Hakimi had got on the overlap.
Raphael Varane’s header from a corner was just off target as Real continued to dominate the opening exchanges.
Espanyol were looking for a first win in eight games, and to avoid what would be a 10th straight LaLiga defeat against Real Madrid.
Pablo Piatti fired well over before striker Moreno was denied by Navas, who threw out a leg to deflect his angled shot wide.
Espanyol had the ball in the net just after the half-hour, but Moreno’s finish from a long-range free-kick by Carlos Sanchez was offside.
At the other end, Marcos Llorente pulled a low effort wide as again Real failed to make the most of their possession.
Bale wanted a penalty just before half-time when his shot cannoned off Victor Sanchez, but the referee was not interested in the appeal for what would have been a harsh handball decision against the Espanyol midfielder.
Early in the second half, Navas had to make a smart save at the near post from Sergio Garcia’s angled effort.
From the resulting corner, Real were fortunate not to go behind as Sergi Darder’s header looped onto the top of the crossbar.
With 20 minutes left, Karim Benzema, who netted a late penalty against Alaves, replaced Isco.
Navas again needed to be alert when producing a smart low stop down to his left from Moreno’s header.
The Real Madrid keeper, though, could do little to prevent Espanyol snatching a dramatic winner deep into stoppage time.
Moments after Ramos, who had been pressed forward by Zidane, was just unable to get on the end of a low ball across the face of goal, the hosts broke quickly with the ball worked out to Garcia on the right.
Garcia pulled the ball back towards the edge of the penalty area, where Moreno arrived to crash it past Navas with almost the last kick of the game and seal Espanyol’s first win over Real Madrid in some 22 matches.
Defeat leaves Real Madrid in third place, 14 points behind leaders Barcelona, who have a game in hand and two ahead of Valencia, but having played one match more.