BARCELONA, Spain (AP) -Real Madrid trailed twice before fighting back with three goals in a seven-minute span to beat Mallorca 5-2 in the Spanish league on Saturday and avoid another slip-up to a low-profile side.
Mallorca entered the match after back-to-back wins and led 2-1 at Santiago Bernabeu Stadium after goals from Emilio Nsue and Alejandro Alfaro, both set up by Giovani dos Santos, with Gonzalo Higuain scoring in between for the hosts.
After a sluggish first half, Cristiano Ronaldo sparked Madrid to life with an equalizer in the 51st that took his league tally to 27 goals this season.
Luka Modric put Madrid ahead three minutes later with a screamer, similar to his Champions League goal against Manchester United, and Higuain added another in the 57th.
Higuain then set up Karim Benzema to polish off the rout in stoppage time.
"We knew that Mallorca was playing well recently and they took the lead twice, but the important thing is that the team was able to pull out the win,'' said Higuain. "We need to keep winning so Barcelona can't relax.''
Also on Saturday, Real Sociedad produced a dizzying attacking display to thrash Valladolid 4-1 and provisionally rise into fourth place.
While able to win against major opponents like Barcelona and United, Madrid's title defense has been undermined due to poor showings to modest Spanish teams this season.
The defending champions trail leader Barcelona by 10 points after losing to opponents such as Getafe, Granada, Real Betis, and Sevilla plus drawing at Osasuna and at home to Espanyol this season.
And it looked like the same pattern of being caught off guard would repeat itself in the first 45 minutes of Saturday's game, until Madrid reacted and quickly imposed itself on the relegation-threatened visitors.
Mallorca coach Gregorio Manzano said he was pleased because "we made the crowd at the Santiago Bernabeu jeer their team.''
"The team came out strong in the first half,'' he said. "We should have tried to hold onto the lead and taken advantage of the opportunities we had to make it 3-1.''
Giovani created Mallorca's sixth-minute opener when he swung a cross in that Nsue sent bouncing into the corner of the net with sharply taken header.
Higuain leveled for Madrid in the 15th from a move started by Modric and a nifty lay-off pass from Pepe.
Madrid's goal didn't change the flow of the match, however, and Alfaro netted his fourth goal in three games by heading in Giovani's corner after Pedro Bigas had flicked it to the far post.
Ronaldo, meanwhile, was growing visibly annoyed as the home fans began to grumble. The Portugal forward slammed his fist into the turf at one moment and threw his arms up in frustration several times as his side failed to find its verve.
Apparently displeased as his star player, coach Jose Mourinho sent on Mesut Oezil and Benzema at halftime.
But it fell to Ronaldo to pull Madrid level again when he met Oezil's corner at the near post and headed it beyond goalkeeper Dudu Aouate.
Madrid erupted and Mallorca was soon overrun.
Modric put Madrid in front for the first time with a blistering strike from outside the area that struck just inside the upright.
Oezil then picked out Higuain arriving unmarked in the area to fire in Madrid's fourth of the night. Higuain renounced a chance at a hat trick by slipping the ball for Benzema to score in the final moments.
In San Sebastian, forward Antoine Griezmann powered Sociedad with a double and Imanol Agirretxe and Xabi Prieto added two more goals as the Basque side put on one of the most commanding performances in Spain's topflight this season.
Sociedad remained with only one loss in its last 18 games and rose three points above Malaga before it hosts Espanyol on Sunday.
Sociedad's fourth goal was an exquisite group move similar to the best combinations crafted by Barcelona.
Griezmann again was fundamental, starting a flurry of one-touch passes by linking up with Prieto, who passed wide for Carlos Vela before rushing forward to receive the ball back and tap it beyond the goalkeeper.
"I liked all the goals, but I'll take away the fourth for the collective work behind it,'' said Sociedad coach Philippe Montanier.
Substitute Javi Guerra scored Valladolid's consolation goal in the 87th.
Elsewhere, Getafe edged out an uninspired Athletic Bilbao 1-0 thanks to Borja Fernandez's goal in the seventh minute, giving the Madrid-based team its fifth win in seven rounds.
Later, Valencai beat Real Betis 3-0.