With Karim Benzema out with an ankle issue, although poised to return for the Champions League last 16 second leg clash with Liverpool on Wednesday, Carlo Ancelotti selected Rodrygo up front in his place.
The coach also opted to play Eduardo Camavinga out of position at left-back again and the French midfielder's mistake helped the visitors move ahead after eight minutes.
Camavinga misjudged a long ball which he allowed to reach Ruben Sanchez, who crossed for striker Joselu to smash into the top corner.
Stirred by Espanyol's goal, Madrid quickly improved in the early afternoon spring sun, and Vinicius fired them level with a superb solo effort of his own.
The Brazilian winger cut inside from the left and drove home to net his 19th goal of the season across all competitions.
Militao headed the champions in front before the break, meeting a sumptuous Aurelien Tchouameni cross, which the midfielder served up with the outside of his boot.
Vinicius blasted over as Madrid looked to press home their advantage and the Brazilian was also knocked to the floor off the ball by Oscar Gil, who was booked.
The forward has been targeted by opposition defenders in recent months and Vinicius appeared winded after Gil's bodycheck.
Rodrygo came closest to extending Madrid's lead when he curled a free-kick over the wall but it struck the crossbar.
Espanyol could not trouble Thibaut Courtois in the final stages, with Martin Braithwaite directing a header a long way off target.
Vinicius was warmly applauded by Madrid fans as he was taken off late on, with Ancelotti giving another brief cameo to young forward Alvaro Rodriguez.
However it was another substitute, Asensio, who wrapped up the win with a cool finish after Nacho's uncharacteristic dribble forward into attack.