The top two will meet in "el clasico" in two weeks' time at Real's Bernabeu stadium.
Barcelona rested some first team players ahead of a mid-week Champions League encounter with English side Arsenal, with Lionel Messi, their star Argentine forward, and Xavi, the Spanish midfielder, on the bench.
Pep Guardiola's team struggled to gain control of the game at the Ono Estadi with Mallorca proving resolute against long spells of Barca possession.
Early on Mallorca put the Catalans under significant pressure, with forward Aritz Aduriz smashing a strike against the post and Victor Valdes, the Barca goalkeeper, having to save a rebound shot, in the second minute.
Xavi and Messi were brought on in the second half and provided a stimulus, with the former's corner eventually reaching Ibrahimovic whose resulting goal took his tally to 15 for the season.
The result leaves Mallorca, who had won 12 of their past 13 matches up until Saturday, in fourth place, but more than 20 points off Barcelona.
Mid-table Malaga drew 1-1 at home to Tenerife on Saturday, leaving Tenerife in the relegation zone.
In the late kickoff, third-placed Valencia had Nikola Zigic sent off for a second yellow card just before half time in a bruising clash at promoted Real Zaragoza.
Already 1-0 down after Carlos Diogo's thumping 41st-minute opener, Unai Emery's side crashed to a 3-0 defeat that leaves them 21 points behind Barca on 53.
Earlier, midfielder Alejandro Alfaro scored from the spot in the 86th minute to snatch a 1-1 draw for relegation-threatened Tenerife at Malaga.
The hosts had Patrick Mtiliga sent off for giving away the penalty after Apono had put Tenerife in front the 66th minute.