Madrid appeared set to record its seventh straight home win in the league after Cristiano Ronaldo scored to cancel out Sergio Garcia’s opener before setting up Fabio Coentrao to put Madrid up after halftime.
But Espanyol substitute forward Juan Albin scored from of a poorly defended corner for a share of the points two minutes from time.
Barcelona can add to its 11-point lead over the defending champion when it hosts second-place Atletico Madrid later Sunday.
The blow to Madrid’s dwindling title defense hopes came just four days after it lost 2-1 at Celta Vigo in the first leg of their Copa del Rey series.
”After a poor first half we were able to level and then go in front, but we didn’t finish it off,” said Madrid midfielder Xabi Alonso. ”You can’t say (the league for us) is over, but you can say it will be harder.”
Elsewhere, Levante rose to fifth place after winning 1-0 at Real Zaragoza, while Rayo Vallecano beat Valencia 1-0 for its first ever victory at Mestalla stadium after 13 winless visits.
Madrid’s troubles this season had been limited to its away games, but a modest Espanyol side was never at a serious disadvantage against the powerhouse.
Espanyol remained unbeaten in three games under new coach Javier Aguirre and managed to end a run of seven straight losses to Madrid in which it had been outscored 21-0.
With Gonzalo Higuain injured and Karim Benzema ruled unfit with a tender ankle before the game, Ronaldo was left to lead Madrid’s attack alongside former Espanyol forward Jose Callejon.
After Madrid playmaker Luka Modric had hit the upright, Espanyol stunned the Santiago Bernabeu crowd in the 31st when Garcia, just back from a four-game suspension for insulting a referee, struck on the break.
Playmaker Joan Verdu used a one-touch pass to play Garcia in behind the defense, and the forward made the most of the chance by pushing forward and firing the ball into the far corner of Iker Casillas’ net.
Madrid was average before Garcia’s goal, and it appeared uncharacteristically sluggish and short on ideas afterward.
But Ronaldo stepped up to level in first-half injury time when he ran into the area and used the sole of his right boot to reach beyond his marker and volley Sami Khedira’s cross beyond goalkeeper Kiko Casilla.
Madrid coach Jose Mourinho sent on winger Angel Di Maria for Modric at the start of the second half, seeking to spark his team.
But it fell to Ronaldo and Coentrao to put Madrid in front in the 48th when Ronaldo found his sprinting fellow Portugal international with a well-placed pass inside the box that he rolled into the net after resisting a tackle.
Madrid pressed forward to try and seal the win, but Casilla made three quality saves, including a one-handed stretch to redirect Di Maria’s blast onto the goal-frame.
Madrid’s effort again sputtered out and for the first time Espanyol took control of the ball and backed Madrid into its own area in the final minutes.
And the payoff came when Madrid allowed defender Hector Moreno to get two touches on a corner before slipping it to the unmarked Albin to fire home.
On Monday, Valladolid visits last-place Deportivo La Coruna, while Real Betis plays Celta Vigo.
On Saturday, it was: Sevilla 0, Malaga 2; Getafe 1, Osasuna 1; Mallorca 0, Athletic Bilbao 1; and Granada 0, Real Sociedad 0.