The Croatian scored a spectacular effort from long range as Jose Mourinho's half-time changes saw his side turn around a 2-1 deficit with three goals in five minutes
An unorthodox lineup featuring Pepe as a defensive midfielder did not have the intended effect for the home side, who struggled with the high ball as Mallorca ended the first half in front through Emilio Nsue and Alejandro Alfaro, who netted either side of a Gonzalo Higuain effort.
But Jose Mourinho's tactical and personnel readjustments at half-time paid off almost immediately, as three goals in five minutes from Cristiano Ronaldo, Luka Modric and Higuain sent the hosts into a two-goal lead before the hour mark, an advantage that they would never relinquish.
Karim Benzema added a fifth at the death, as Madrid keep their hold on second spot in the table, moving four points clear of third-placed Atletico Madrid, who visit Osasuna on Sunday.
With Pepe pushed further forward, Raphael Varane returned to displace Raul Albiol in the centre of defence, while Jose Callejon made way for 20-year-old Alvaro Morata out wide.
Mallorca would make the brighter start to the match though, due in no small part to the enterprise of Giovani dos Santos. The former Barcelona winger did brilliantly to beat his man and hang a cross towards the far post, where Nsue was waiting to head home the opener.
But Madrid were soon back down the other end of the pitch, and Higuain would force Dudu Aouate into an unconventional save with his chest from an odd angle.
Higuain would make no mistake on the quarter-hour mark though, smashing into an open goal after Pepe had done enough to harness a Modric through pass and roll the ball into his path, despite suspicions of offside.
But six minutes later, Mallorca were back in front, when Dos Santos’ corner was flicked on by Pedro Bigas, and nodded in at the far post by the unmarked Alfaro.
The scoreline did not always reflect the tone of the match, as Mallorca spent large periods without the ball, but their stout defending was enough to frustrate the home side.
However, Ronaldo nearly broke their resilience just before the half-hour mark when his attempt from Morata’s lay-off clipped the woodwork on its way out.
But Mallorca’s danger lay chiefly in their aerial threat, and they nearly gave Madrid another painful demonstration when Dos Santos’ corner was nodded inches wide minutes before the interval.
Mourinho moved quickly to rectify the situation at the break, introducing Benzema and Mesut Ozil for Arbeloa and Morata, while shifting Ramos to right-back and dropping Pepe into his natural position at the heart of defence.
And the effect of his half-time readjustment were seen within moments, when Ozil’s corner was guided into the corner by the head of Ronaldo just after the restart.
Barely a minute later, Modric sent the hosts into the lead for the first time with a sensational swerving first-time strike from 25 yards out that left Aouate with absolutely no chance.
The onslaught was not done, as almost straight from kickoff, Ozil meandered to the byeline and cut back for Higuain to turn home Madrid’s fourth goal.
By the time the dust had settled, the only question remaining in the game was how many goals Madrid would score with Mallorca completely floored by their ruthless turnaround.
Higuain, Ozil and Ronaldo all spurned chances in the second half, but the fifth goal would eventually arrive at the death when the Argentine squared to Benzema, who made no mistake from barely a yard out.
And that served as the last kick of the game, as a day of experimentation for Mourinho ended successfully, and left him with plenty to ponder for his side's upcoming European clashes with Galatasaray.