The home side went a goal down after just 17 seconds, but came back to record a comfortable win despite the Argentine's second-half dismissal, largely thanks to the Portuguese star
Madrid had lost to Levante last weekend and failed to beat Racing Santander in another disappointing result on Wednesday, but instead of reacting positively early on in this match, Jose Mourinho's men got off to the worst possible start as they conceded after just 17 seconds.
Michu pounced on the rebound after Iker Casillas had spilled Raul Tamudo's effort from outside the box to give the visitors the shock lead.
It was the fastest ever goal from a visiting side at the Santiago Bernabeu and hardly the start Madrid were looking for after two poor results in the last seven days.
It took a while for them to react, as well, and Rayo continued to look dangerous on the break.
Raphael Varane, in the side alongside Raul Albiol as both Pepe and Ricardo Carvalho missed out through injury, shot wide for Madrid and Kaka - in for Mesut Ozil - also came close, but Lass almost shocked the home side as he fired over after 25 minutes.
Three minutes later, the other Lass, Diarra, was substituted as Mourinho sent on Ozil, and Madrid improved instantly.
The German tested Dani Gimenez in the Rayo goal shortly after coming on and seven minutes before half-time, Madrid levellled, when Kaka set up Ronaldo and the Portuguese fired through the keeper's legs.
That was 1-1 and it soon became 2-1 as Xabi Alonso and Sergio Ramos combined for Gonzalo Higuain to give the hosts the lead on the stroke of half-time with a simple finish.
After the break, Jose Maria Movilla then upended Kaka in the box and Ronaldo converted from the spot to make it 3-1.
Michu reduced the deficit as he fired home at the far post shortly afterwards, and even though Casillas pushed the ball out, replays showed the striker's effort had crossed the line.
And it looked as if the visitors may make a real game of it as Di Maria handled and was sent off for a second bookable offence.
But Varane back-heeled to make it 4-1 and score his first official goal for his new club midway through the second half.
Substitute Karim Benzema then blasted a fifth after good work from Ozil six minutes later, just after Casillas had saved from Movilla at the other end.
And Ronaldo rounded off a comprehensive victory with his hat-trick seven minutes from time, as he slotted home from the spot after Dani had brought down the Portuguese.
Madrid now have 10 points, two less than leaders Betis, who have a game in hand, and one less than Barcelona, in action against Atletico Madrid in Saturday's late match.