Goals from Kylian Mbappe and Vinicius Junior in the first half secured the three points, but a spirited Rayo side made it a nervy finish with a strike from Pedro Diaz just before the break.
The victory marked only the second league win in six matches for Los Blancos, who now sit joint-top with Barcelona on 57 points, ahead on goal difference, while Atletico Madrid linger one point back in third after their 2-1 defeat to Getafe earlier that day.
Manager Carlo Ancelotti hailed the result as a job well done despite a performance that lacked polish in the second half. "The feeling is good because the objective was to win," Ancelotti said in his post-match press conference. "The first half was very good, it could have been 3-0 or more, but we missed chances, and their goal made it trickier after the break.
"We had opportunities, but at 2-1 with 15 minutes left, you focus on avoiding trouble and defending well. People might not have liked it, but with our schedule, Champions League, Copa del Rey, it's tough to keep intensity for 90 minutes."
The match kicked off with purpose from Real Madrid, who were eager to capitalise on Barcelona's postponed fixture and Atletico's earlier slip-up. Mbappe broke the deadlock on the half-hour mark, latching onto a loose ball and rifling it into the far corner. Moments later, Vinicius Junior doubled the lead with a dazzling solo run, slaloming past Rayo defenders before slotting home.
However, Rayo hit back before halftime when Pedro Diaz's thunderous effort crashed off the bar and over the line, confirmed after a VAR check.
The second half saw Real Madrid retreat as Rayo grew into the game, though neither side carved out clear chances. Vinicius came closest late on, meeting a Luka Modric cut-back only to fire wide, while Rayo's possession dominance failed to yield an equaliser. "We started strong, but after their goal, we lost some control," Ancelotti admitted. "Still, we got the points, that's what matters."
With a crucial Champions League last-16 second leg against Atletico Madrid looming on Wednesday, following a 2-1 first-leg win, Ancelotti provided injury updates on key players. "Thibaut Courtois has a minor issue, but I think he'll be fine for Wednesday," he said. "Antonio Rudiger's been under the weather with flu, but we're hopeful he recovers too. The squad looks fresh despite the calendar. If we play like we did in the first half today, we've got a great shot at progressing."
In a recent X post, Mbappe posted: "Big win, great team effort, onto the next one."
For football fans, this result keeps the La Liga title race tantalisingly tight, with Spain's big three locked in a dogfight and Real Madrid showing they can grind out results even when not at their sparkling best.