An early goal by Chori Dominguez gave the Madrid side the perfect start and Piti wrapped up the points by netting on 77 minutes.
Espanyol had an early chance to take the lead, with Rayo goalkeeper Ruben Martinez nearly getting his team into trouble. His indecision allowed Sergio Garcia a shot at goal, but the effort was too weak and the Rayo stopper saved himself from embarrassment.
Barely a minute later, the hosts were in front. Jose Casado delivered a through-ball to Leo Baptistao, whose electric pace took him into the left-hand side of the box before he delivered a cross which Dominguez converted with his knee to give Paco Jemez's side the lead on nine minutes.
Sergio Garcia squandered Espanyol's only other decent chances of the first half, first hitting his shot straight at Ruben from the edge of the area and then shooting wide after controlling a long punt upfield by goalkeeper Kiko Casilla.
Dominguez had two further attempts before half-time, forcing a save from Casilla with a powerful long-range effort and then sending a bicycle kick well over the bar on the stroke of half-time.
After keeping his side in the game in the first half, Casilla was on hand on several occasions to prevent Rayo from doubling their lead right after the restart, keeping out two efforts from Baptistao and one from Jose Carlos.
However, it was a misjudgement by the goalkeeper which led to Rayo's second goal.
A hopeful long punt forward from the Rayo defence cleared the Espanyol back line and Piti ran into the path of the loose ball. Casilla came flying out of his area in an attempt to get there first but was too slow, and the forward slid the ball past him to score from just outside the area.
The second goal killed off any hope of an Espanyol comeback, although Christian Stuani came close to grabbing a consolation goal in injury time when his powerfully struck volley was superbly kept out by Ruben.
Javi Fuego and Leo Baptistao both picked up late yellow cards which means they will play no part in next weekend's match with Barcelona at the Nou Camp due to suspension.
The victory takes Rayo to 41 points which all but guarantees their survival in the top flight for another season with 11 games left, a welcome contrast from last term when they only avoided relegation thanks to an injury-time winner on the last day of the season.
Javier Aguirre's side have now gone three matches without a win but remain nine points clear of the drop zone.