Victories for Barcelona and Atletico Madrid turned the pressure up on Real ahead of their late kickoff, but a resounding second-half performance put the capital city side back in the title race.
Madrid had another chance to take the lead shortly after when Gareth Bale found space outside the opposition box.
The Welshman slid the ball through to Fabio Coentrao, who in turn delivered a cross to the near post which was turned behind by Roberto Trashorras.
Bale had a role to play when Los Blancos eventually made the breakthrough on 15 minutes, picking out Cristiano Ronaldo, who charged into the area before finding the bottom corner of the net to score his 44th goal of the campaign.
After hitting Rayo on the counter-attack, Bale had a brilliant opportunity to extend Real's real, but he lost his footing as he was about to pull the trigger and the chance went begging.
Madrid continued to probe and found a third after Angel di Maria unselfishly laid the ball off to Bale to tap home from close range on 69 minutes.
Bale added his second and Real's fourth two minutes later, this time going on a solo run through the heart of Los Franjirrojos' defence and finding the bottom corner of the net, while Alvaro Morata added goal number five with a curling effort 10 minutes from time.