hosts rallied after the break.
Cristiano Ronaldo, Luka Modric and Gonzalo Higuain, with his second of the game, netted in a six-minute spell and substitute Karim Benzema notched a fifth goal at the end to leave Jose Mourinho's side in second place with 61 points and 10 games left.
A seventh straight victory in all competitions left the champions 10 points behind leaders Barcelona. French winger Antoine Griezmann scored twice, the second with a spectacular volley, as Real Sociedad battered visiting Real Valladolid 4-1 to go fourth with 47 points.
Sociedad are 10 points behind third-placed Atletico Madrid, having pushed Malaga down to fifth on 44.
Champions League quarter-finalists Malaga host Espanyol on Sunday. Getafe are eighth with 42 points after Borja scored the only goal in a 1-0 home win over Athletic Bilbao.
Mallorca struck first at the Bernabeu when the lively Giovani dos Santos whipped in a cross and Emilio Nsue nodded the ball in from the edge of the area in the sixth minute.
Madrid lined up with an unfamiliar midfield that included Modric and Pepe and the two combined well to help set up Higuain for the equaliser in the 15th minute.
Mourinho's team have often struggled at set pieces this season and they were undone again in the 21st minute when Alejandro Alfaro was left unmarked at the far post to head home a flicked-on corner.
Madrid displayed a different attitude after the break with Mesut Ozil replacing youth-team striker Alvaro Morata. A corner from the German found Ronaldo in the 52nd minute and he nodded his 27th league goal of the season.
Modric fired Madrid in front from long range two minutes later and Ozil dribbled to the touchline before pulling the ball back for Higuain to make it 4-2. Argentine Higuain then squared the ball for Benzema to walk the fifth goal into an empty net in stoppage time.
Man Utd 15 clear
London: Manchester City's fingertip hold on their Premier League title was further loosened when a 2-0 loss at Everton followed by runaway leaders Manchester United's 1-0 win over Reading left them praying for a football miracle.
United needed no second invitation to open a 15-point lead in the title race although only Wayne Rooney's deflected early shot separated them and second-bottom Reading at Old Trafford.
Alex Ferguson's side never required top gear as they rolled on towards a 20th English title with their 24th victory in 29 league games this season, although the Scot refused to accept that the race was won.
"We have got Sunderland away in our next game, which is always a tough place to go, and then we face Manchester City at home. You don't get points and medals for being complacent," said Ferguson.
On Sunday, Dimitar Berbatov dented his former side Tottenham's Champions League qualification ambitions in a significant way, as he scored the only goal of the game in Fulham's 1-0 win at White Hart Lane.