Real’s misery was completed 17 minutes from time when right-back Alvaro Odriozola was sent off for a second bookable offence.
Odriozola had been walking a tightrope from the 19th minute, and he slipped off it when he foolishly challenged Lago Junior and left Real one man short.
Mallorca had to defend for long periods, especially in the second half as a white-shirted wave came towards them, but Real lacked a cutting edge and rarely tested home goalkeeper Manolo Reina.
It was Mallorca’s best win since their promotion from the Segunda Division and moved them out of the relegation spots and into 14th place.
Real were without injured trio Gareth Bale, Luka Modric and Toni Kroos, and summer signing Eden Hazard was also missing after his wife had given birth.
So Luka Jovic made his first league start in nearly a month to join Karim Benzema in attack.Isco tested Mallorca goalkeeper Reina with an early effort but Real were soon behind.
Odriozola allowed Lago Junior to cut inside him onto his right foot and curl a splendid shot past Thibaut Courtois – his first LaLiga goal coming two seasons after he was playing in the third tier for Malaga.
Mallorca thought they had doubled their lead after 14 minutes when Ante Budimir drove home but the assistant referee had correctly flagged for offside.
Real dominated as the half wore on with Benzema striking the crossbar from close range and Reina holding Marcelo’s powerful 20-yard shot.
Mallorca sent on full-back Lumor Agbenyenu for the second half and he tried his luck from distance within 30 seconds, his rising shot just clearing Courtois’ crossbar.
But the pattern of the first half was soon re-established as Real set up camp in Mallorca territory.
Reina held Benzema’s deflected strike and Sergio Ramos sent a 25-yard free-kick over the bar.
However, Real often lacked composure around the edge of the penalty area as Mallorca got bodies around the ball.
Mallorca made a second substitution near the hour-mark, and curiously it was Japanese teenager Takefusa Kubo.
The 18-year-old is on a season-long deal from Real and was only able to feature against his parent club because of a change of policy on loan players at the Bernabeu.
Real were still struggling to create clear-cut chances when Odriozola dived in to stop Lago Junior to receive his second yellow card.
Reina had to collect Eder Militao’s header when James Rodriguez floated a free-kick into a crowded penalty area.
But, in truth, Mallorca saw out the closing stages in comfort and well worth their unlikely victory.