Pepe's second-half header clinched a much-needed win for Real Madrid in their pursuit of Barcelona and Atletico Madrid in the Spanish title race.
Carlo Ancelotti's side moved within three points of the top two, despite a disjointed display against Espanyol.
Ballon d'Or favourite
Cristiano Ronaldo suffered a rare off day, fluffing a first-half chance inside the six-yard box and curling wide late on.
But Pepe's towering header from Luka Modric's delivery clinched a vital win.
Despite their profligacy, Los Blancos were rarely threatened by a mid-table Espanyol side and looked comfortable as they recorded their seventh straight win in all competitions.
In fact, they have not been beaten
since the 2-1 reverse at Barcelona
on 26 October. But the defeat at the Nou Camp, coupled with
a 1-0 home loss
to neighbours Atletico, has left Real playing catch up in the title race.
The third-placed side knew their trip to Espanyol was one where they could not afford to drop points after seeing
Atletico hold leaders Barcelona to a goalless draw
Espanyol started on the front foot as they hassled Real from the kick off and could have taken a third-minute lead when Uruguayan forward Cristian Stuani headed wide.
But Madrid gradually found their rhythm after riding out the early pressure, creating all of the best goalscoring opportunities.
Ronaldo's remarkable year
"It has been Cristiano Ronaldo's year, and while a Ballon d'Or would be the icing on the cake, he does not need the Fifa's top player award to prove it."
Portugal forward Ronaldo, who is expected to be named the world player of the year at Monday's Ballon d'Or ceremony in Switzerland, failed to cleanly connect with Karim Benzema's square pass before the France striker headed past the Espanyol post in stoppage time.
However, Real needed just 10 minutes of the second half to make their breakthrough. Portugal defender Pepe was left totally unmarked as he nodded into the far corner from Modric's deep free-kick.
World record signing Gareth Bale started his first La Liga game in almost a month after a calf injury, but barely featured before being substituted with a quarter of an hour remaining.
Real continued to press, without being seriously tested at the other end, only for Ronaldo to miss two more clearcut opportunities.
Firstly, the 28-year-old was denied by a superb one-handed save from Espanyol goalkeeper Kiko Casilla, before delicately bending wide with the home goal gaping.
- 13 Casilla Cortés
- 16 López Rodríguez
- 18 Fuentes Hernández
- 03 Rodríguez
- 19 Colotto
- 15 Moreno
- 25 Torje Booked (Sabrosa - 65' )
- 04 Sánchez Mata
- 24 Córdoba Booked
- 22 Fernández Iglesias (Lanzarote - 65' )
- 08 Stuani (Afonso Fernandes - 84' )
- 01 Parreño Boix
- 06 da Silva Junior
- 10 Afonso Fernandes
- 11 Capdevila
- 12 Lanzarote
- 20 Sabrosa
- 23 González Casanova
- 25 López
- 15 Carvajal (Arbeloa - 91' )
- 12 Marcelo
- 14 Alonso
- 03 Pepe
- 04 Ramos
- 19 Modric Booked
- 22 Di María
- 09 Benzema (Illarramendi - 90' )
- 11 Bale (Jesé - 76' )
- 07 Ronaldo
- 01 Casillas
- 17 Arbeloa
- 18 Nacho
- 20 Jesé
- 21 Morata
- 23 Isco
- 24 Illarramendi
Ref: José Antonio Teixeira Vitienes