Real barely had to shift into top gear at the Bernabeu, where Ronaldo surpassed Raul with his 324th goal in his seventh season in the Spanish capital.
Barca squandered a host of chances, looked shaky in defence and needed a brilliant Neymar performance to come from behind and see off a Rayo side who played attractive attacking football at the Nou Camp.
The contrasting victories for Spain’s injury-hit big two lifted them to 18 points from eight matches, with Real ahead on goal difference.
Villarreal, the surprise early front-runners, slipped to third but can reclaim the lead with a win at home to fourth-placed Celta Vigo on Sunday, when Atletico Madrid, who are fifth, play at Real Sociedad.
Marcelo fired Real ahead in the 27th minute when he exchanged passes with Ronaldo and blasted the ball past Ruben in the Levante goal.
Ronaldo made it 2-0 three minutes later when he cracked a trademark long-range effort into the corner, ending a rare four-match goal drought in Spain’s top flight for the Portugal captain, his joint-worst run since he joined Real in 2009.
Substitute Jese skipped past his marker and drove the ball high into the net to make it 3-0 eight minutes from time as Real secured a morale-boosting win ahead of Wednesday’s Champions League Group A match at Paris St Germain.
“Cristiano took on the responsibility because we lacked forwards,” Real coach Rafa Benitez, missing regulars Karim Benzema, James Rodriguez, Luka Modric and Sergio Ramos through injury, told a news conference. “He had to lead the team and that’s what he did.”
Barca, missing talisman Lionel Messi and captain Andres Iniesta, were rocked when Javi Guerra gave Rayo a surprise 15th-minute lead.
Ivan Rakitic and Luis Suarez had earlier failed to beat Tono when through one-on-one with the Rayo keeper but Barcelona were level in the 22nd minute when Neymar won and converted a penalty.
The Brazil forward, clearly trying to lift the team in Messi’s absence, was felled again in the area in the 31st and successfully dispatched his second spot kick.
Barca keeper Claudio Bravo had to make several good saves as Rayo came out strongly after the break and the weakness of the European champions’ back line will be a worry for coach Luis Enrique ahead of Tuesday’s game at BATE Borisov.
Neymar struck in the 69th and 70th minutes to make it 4-1, becoming the first Barca player other than Messi to score four in a match since Samuel Eto’o in 2008, before he crossed for Suarez to clip the ball home 13 minutes from time.
Jozabed took advantage of more poor defending to score Rayo’s second in the 86th minute.
“He (Neymar) has been electric since the start of the season,” Luis Enrique told a news conference. “When he gets into the area there is nobody who can stop him.”
Sevilla’s stuttering start to the season continued when the Europa League holders, who play at Manchester City in the Champions League on Wednesday, drew 1-1 at modest Eibar and are 11th on nine points.
Valencia warmed up for Tuesday’s match at home to Ghent in Europe’s elite club competition with a 3-0 victory against Malaga that lifted them to eighth with 12 points.