Zinedine Zidane’s side were the only team in the division without a loss ahead of their visit to the islanders – in 18th place before this match – but never really found their rhythm in a disjointed display at Son Moix.
Ivorian forward Lago Junior scored the game’s only goal as he raced down the left flank, cut inside, evaded the attentions of Alvaro Odriozola and curled a lovely effort low into the bottom corner with his right foot after just seven minutes.
Karim Benzema saw a shot rebound off the turf and onto the crossbar later in the half, but Real were toothless without a number of their regulars as Zidane rang the changes.
Gareth Bale and Luka Madrid sat out after picking up knocks on international duty, while Eden Hazard was given the weekend off following the birth of his fourth child and Toni Kroos was kept in reserve despite recovering from a recent groin injury.
Zidane will have been looking ahead of the Champions League clash away to Galatasaray on Tuesday, but he may have made too many changes as a midfield featuring Casemiro, Isco, James Rodriguez and Vinicius Junior lacked balance and Luka Jovic made little impact alongside Benzema.
The French coach sent on Rodrigo, Fede Valverde and later Brahim Diaz, but Madrid were reduced to crosses and long-range efforts in the closing stages.
Real’s task was also made more difficult as Odriozola was dismissed for a second bookable offence late in the game and the home side held out for a famous win in front of their ecstatic fans.
Madrid drop to second with nine games played, a point behind Barcelona after the Catalans beat Eibar 3-0 earlier on Saturday.
Mallorca, meanwhile, climb to 14th with their third win of the campaign and are now two points clear of the drop zone.