Real and Barca maintain perfect starts
Real made it five wins out of five thanks to a Karim Benzema double and a sublime curler from Kaka and lead with 15 points, ahead of Barca on goal difference.
Sevilla, who won 4-0 at Athletic Bilbao, are third on 12, while substitute Maxi Rodriguez struck in added time to earn struggling Atletico Madrid a 2-2 draw at Valencia.
Ibrahimovic needed just 10 minutes to score his fifth goal in five games after coming off the bench for the injured Thierry Henry in the 29th minute of a bad-tempered clash.
Lionel Messi lifted the ball over the static Malaga defence and the Sweden striker controlled with his chest and fired in.
Defender Gerard Pique poked home a Xavi freekick three minutes after replacing Dmytro Chygrynskiy, who appeared to have picked up a knee problem, in the 56th minute.
In a match littered with yellow cards, Malaga defender Weligton looked fortunate to stay on the pitch after TV replays showed him treading on Messi's ankle.
The referee later sent Barca assistant coach Tito Vilanova off the bench for protesting a decision and with five minutes to go showed Malaga forward Albert Luque a straight red card for a wild challenge on Daniel Alves.
"It was a very aggressive match that took a lot out of us," Barca coach Pep Guardiola told a news conference.
Asked whether the La Liga campaign was already a two-horse race between Barca and Real, he added: "Madrid has economic might but we have too and the players make the difference. In that sense we have a big advantage."
Brazilian playmaker Kaka, a second-half substitute earlier at the Bernabeu, bent in a stunning shot to end any hopes of a fightback from promoted Tenerife after France striker Benzema had netted twice in 11 second-half minutes.
Tenerife are dubbed Real's 'Cursed Island' by the Spanish media after the Canary Islanders twice deprived the Madrid club of the league title in the early 1990s.
After a closely-fought first half with few clear chances, Benzema rose early in the second period to nod in Xabi Alonso's cross and then outmuscled defender Manuel Martinez and curled a precise shot into the far corner.
The Real defence looked far from solid in the second half despite the return of Portuguese international Pepe to the starting lineup after a 10-match ban.
Forward Nino narrowly missed with a lob with Iker Casillas off his line and a mistake from the Real keeper almost let in Julian Omar before Kaka beat the keeper from the edge of the penalty area.
"We were very bad in general in the first half and the substitutions obviously helped," Real coach Manuel Pellegrini said at a news conference.
"It was clear that Kaka gave the team a boost but we have a Champions League match (against Olympique Marseille on Wednesday) and we tried to win the game with him."