Real dominated the earlier possession, with Marco Asensio and Nacho Hernandez exchanges passes which led to a shot from outside for Isco that shinned wide from 13 yards.
The domination continued for the hosts, but there was to be stern defending needed from Sergio Ramos to cut any dangers on the break from the visitors.
The visitors created another big chance with the ball falling to Pablo Piatti, who drilled it across goal from a tight angle on 15 minutes.
It became a tightly contested affair, with both sides cancelling each other out as no forward play happened consistently.
Espanyol were growing in confidence towards halftime and at some stage matches Real pound for pound.
But their confidence were shattered by Asensio on 42 minutes after he turned from the right side to finish past Diego Lopez in the bottom corner.
There were slight calls for offside, but after consulting the VAR team, the man in the middle awarded the goal.
A darting run from Isco down the byline nearly played in Luka Modric who unleashed with a shot but Lopez was equal to the task.
Real made their first change of the evening when Mariano Diaz replaced Karim Benzema on 60 minutes.
The Rubi nearly pounced on a mistake from Ramos after six minutes where their forward Borja Iglesias lifted the ball over Thibaut Courtois but hit the crossbar.
On 76 minutes, a brilliant save from Lopez kept out Ramos from using his trademark ways to increase the lead after venturing forward from the back.
In the last few minutes, Los Blancos were forced into thorough defending as the visitors threw bodies forward to get the equaliser but the European champions stood firm for the win.