In the 40th minute, Eric García unleashed a powerful shot from the edge of the penalty area, but goalkeeper Marko Dmitrović produced a fine save.
The teams traded attacks after the break until Paul Lozano finally broke the deadlock for Espanyol in the 56th minute.
In the 84th minute, Barça manager Hans Flick introduced Frenkie de Jong for Ferran López.
Three minutes later, Yamal netted the third after a superb through ball from substitute Casado, punishing the Espanyol goalkeeper’s advance.
Rashford, who had replaced a teammate in the 64th minute, then finished off the rout in the 89th minute, slotting home a stunning assist from De Jong.