Villarreal were ahead within a minute thanks to Perbet, who found space in the box and made no mistake from Hernan Perez's delivery.
Espanyol came into the game more and more after that before Giovani dos Santos spurned a chance to double the lead on the break, firing at the goalkeeper after collecting Perbet's pass.
The Mexican had an even better chance moments before half time, but again failed to beat the goalkeeper after being played clean through.
Cani got more involved for Villarreal after the break, almost managing to play in Dos Santos and then Perbet, but on both occasions the defence cleared.
It was Villarreal who scored the second goal, breaking at speed just over 20 minutes from time as Cani drove into the box and fired across goal for Pereira to tap in.
The visitors did not give up there and were rewarded with a fine goal 10 minutes from the end, when Garcia turned on the edge of the box and fired into the corner.
A nervous Villarreal eventually held out though to end Espanyol's unbeaten run and move into the top four.