Ronaldo treble keeps Real hopes alive
The world's most expensive player single-handedly inspired Real after they had been stunned by Mallorca's early goal.
It was his first hat-trick in La Liga and took his tally for the season to 25, one behind team-mate Gonzalo Higuain who scored Real's fourth.
Manuel Pellegrini's side moved to 92 points, one behind Barca with two matches left after winning what was considered the toughest game of their title run in.
Barcelona visit Sevilla on Saturday when Real are at home to Athletic Bilbao. On the final weekend of the season Barca host relegation-threatened Real Valladolid and Real visit struggling Malaga.
Mallorca slipped out of Spain's last Champions League qualification place to fifth on 59 points, with Sevilla having earlier hammered Racing Santander 5-1 to climb on to 60.
Aritz Aduriz stooped to nod past Iker Casillas when a half-cleared corner was knocked back into the area, but the goal only served to make Ronaldo increase his workrate at the Ono Estadi.
He ran at the home defence at every opportunity and levelled when Sergio Ramos picked out his run with a long pass over the top in the 26th minute, and the Portuguese bravely made it to the ball ahead of Dudu Aouate to loop the ball into the net.
Ramos crossed again for the second just after the re-start, when Ronaldo chested down and poked the ball past Aouate, but his third was the pick of the bunch, as he accelerated through three defenders before shooting low into the net.
Not to be outdone, Argentine Higuain scored a wonderful fourth, lobbing Aouate on a breakaway near the end.
Other than Ronaldo, Casillas played his part by saving twice in one-on-one situations when the scores were still level at 1-1.
Alvaro Negredo and Jesus Navas, who both have a chance of making the Spain World Cup squad, were on the scoresheet for Sevilla in Santander.
Striker Negredo scored twice, the last a thunderous far-post volley, and winger Navas bagged one along with Diego Capel and Frederic Kanoute, to leave free-falling Racing deep in the relegation trouble.
The Cantabrians slipped down to 17th, one point above the bottom three with 36 points, the same as Malaga in 16th who have a superior head-to-head record. Malaga drew 1-1 at Athletic Bilbao.
Tenerife are 18th, Valladolid are 19th with 33 points after a 3-1 reverse at Europa League finalists Atletico Madrid.
Bottom club Xerez are hanging by a thread on 30 points, their superior head-to-head record over Malaga the only thing that is saving them from the drop down to the second division.