Barcelona stayed ahead with 35 points even though it had the weekend off because it was playing the Club World Cup in Japan, a tournament it won earlier Sunday. Atletico, also with 35 points but behind on goal difference, missed a chance to take sole possession of the lead after a 1-0 loss at Malaga.
Real Madrid was losing with both teams at full strength at the Santiago Bernabeu Stadium, but it took advantage of two early red cards to Rayo Vallecano to get back into the game and ease the pressure on coach Rafa Benitez, who was loudly jeered before the match.
It was the first time a team scored 10 or more goals in the league since Madrid trounced Elche 11-2 in 1960.
Rayo coach Paco Jemez blamed the refereeing for the rout.
"It's been a while since I've last seen something like this," he said. "It's a shame. This doesn't benefit anybody, not Real Madrid, not our team, not Spanish football."
Danilo opened the scoring in the third minute before Antonio Amaya equalized in the 10th and Jozabed Sanchez put Rayo ahead in the 12th. But Rayo lost Roberto "Tito" Roman to a straight red in the 14th after a foul on Toni Kroos and Madrid leveled through Bale in the 25th.
Raul Baena was then sent off for a second bookable offence in the 28th after bringing down Sergio Ramos in the penalty area. Ronaldo netted the resulting spot kick to give Madrid a 3-2 lead. The hosts then made the two-man advantage count with a flurry of goals.
Bale netted his second in the 41st and completed his hat-trick in the 61st after Benzema and Ronaldo had struck in the 48th and 53rd, respectively.
Bale added a fourth in the 70th before Benzema netted two more in the 79th and 90th minute for the game's second hat trick.
It was the first time Bale scored four goals for Real Madrid. Benzema had scored five times in Madrid's previous two games at home, including three in the 8-0 win over Malmo in a Champions League game two weeks ago.
"We started well but we didn't keep the same intensity," Real Madrid goalkeeper Keylor Navas said. "They took advantage of their opportunities, but then we took control of the game again and got an easy win."
Madrid's victory made things easier for Benitez, who has been heavily criticized by fans and local media despite having the support of president Florentino Perez. Fans booed the coach before the match and some even jeered after the final whistle, despite the huge victory.
"It's normal the fans jeer because we are not in first place, which is where we need to be," Navas said. "We are with the coach. We need to be united if we want to be in contention at the end of the season. We can't put the blame on anybody."
Call for Benitez's departure increased after the team's 1-0 loss at Villarreal last weekend, which kept Madrid from cutting into Barcelona's lead. Former star playmaker Zinedine Zidane has been widely touted by local media as Benitez's replacement, and rumors of his imminent departure only increased after Jose Mourinho and Pep Guardiola became available on the market.
Last week, Perez dismissed the possibility of signing Mourinho again right now and expressed his full support to Benitez, saying he is the right man to put Madrid back on track.
"We started scoring and the supporters were happy," Benitez said.
Real Madrid has been in crisis since a 4-0 home loss to Barcelona a month ago, which was followed by an embarrassing elimination in the Copa del Rey for using an ineligible player in a match against third-tier club Cadiz.
Rayo Vallecano was coming off three straight league losses in the league and is only 18th in the standings with 14 points.
In Malaga, striker Charles Dias scored in the 86th to give the hosts a 1-0 win over second-place Atletico Madrid, which played with 10 men after Gabi Fernandez was sent off in the 56th minute. The result ended Atletico's 15-game unbeaten streak. It had won nine straight matches before travelling to Andalucia.
In other results Sunday, fourth-place Celta Vigo defeated Granada 2-0 to reach 31 points from 16 rounds, while fifth-place Villarreal beat Real Sociedad 2-0 to get to 30 points.