The Portuguese international pounced on a loose ball at a 54th-minute corner and sent it through a crowd of players into the net for his 29th goal of the season, two ahead of Barca forward Lionel Messi at the top of the scoring chart.
Real’s victory at promoted Rayo’s sun-drenched stadium in the south east of the Spanish capital put Jose Mourinho’s side 13 points clear of second-placed Barcelona ahead of the champions’ game at Atletico Madrid later on Sunday.
Real have 64 points from 24 matches, with Barca on 51 in second and Valencia 11 points further back in third.
Mid-table Rayo, hosting their more illustrious neighbors for the first time in nine years, had the best chance of the first half when forward Piti crashed an angled shot past Iker Casillas that hit the inside of a post and bounced away along the line.
Real were missing winger Angel Di Maria and striker Karim Benzema, both injured, and struggled to create chances against a resolute Rayo, who were coming into the game on a run of three consecutive wins and were roared on by their flag-waving faithful enjoying the warm weather.
They made Real suffer in the closing stages and squandered three clear chances for an equalizer, first when Sergio Ramos gave the ball away in a dangerous position.
It eventually fell to Michu but he skewed his shot over the bar before Casillas was forced into a superb diving save that stopped a thunderous long-range strike from Jose Manuel Casado.
Michu was shown a straight red card two minutes from time for a relatively innocuous-looking tackle from behind on Real’s Germany midfielder Sami Khedira and Rayo forward Emiliano Armenteros somehow failed to score when the ball fell to him on the line with Casillas stranded.
In an entertaining match earlier on Sunday, Athletic Bilbao missed a chance to climb above Levante into fourth and a Champions League qualification place when they were held to a 2-2 draw at improving Villarreal.
The home side, whose season has been wrecked by injuries to key players, took a 10th-minute lead through former Spain midfielder Marcos Senna before goals from Fernando Llorente and Markel Susaeta put the Basque club 2-1 ahead.
Nilmar equalized in the 68th minute to leave Villarreal in 17th on 27 points and Bilbao in fifth on 34, one behind Levante, who won 2-1 at seventh-placed Espanyol on Saturday.
In Berlin, winger Franck Ribery dazzled fans and scored both goals as Bayern Munich beat Schalke 04 2-0 on Sunday, lifting the Bavarians back into second place and a point behind Bundesliga leaders Borussia Dortmund.
Ribery cleverly chipped the ball over charging keeper Timo Hildebrand and then slotted into an empty goal from 20 meters as Bayern looked sharper than in their last five league games where they had taken only two wins.
They also lost their Champions League round of 16 first leg 1-0 at Basel in midweek.
The Frenchman, who combined very well with fellow winger Arjen Robben throughout the game, then grabbed his 10th league goal early in the second half, firing in from a tight angle inside the box, minutes after Bayern’s Holger Badstuber rattled the bar with a powerful header.
The win lifted Bayern to 48 points, one ahead of third-placed Borussia Moenchengladbach. Schalke remain fourth on 44.