
The crucial win - with late goals from Rafa Marquez and Samuel Eto'o - leaves Barca with 37 points from 18 games.
Real, who are at home to misfiring Zaragoza on Sunday, currently have 41 points from 17 games.
The win in Palma will vindicate the many Barca fans who would like to see Ronaldinho sold off. The Brazilian playmaker was absent due to tendinitis in his left knee - and was not missed at all.
Mallorca looked more dangerous in the first half, with Daniel Guiza and Angelos Basinas going close.
Barca stepped up the tempo in the second half and went ahead in the 63rd minute, when Marquez headed in a near-post corner from Xavi Hernandez.
Thierry Henry came off the Barca bench a minute later and three times came close to adding a second.
Veteran playmaker Ariel Ibagaza was his lively old self for Mallorca, but the local forwards were rarely on the same wavelength as him.
In the second minute of injury time Eto'o made it 2-0 with a powerful near-post drive from outside the penalty box.
"Tonight it was really important for us to win," Barca captain Carles Puyol told Cadena COPE, "and we deserved to do so."
Later on Saturday comes an interesting clash between two teams who have caught the eye this season, Espanyol and Villarreal.
Espanyol go into the game in third place, on 33 points. Villarreal are fourth on 32.