The 39-year-old Swedish striker put Milan in front after 13 minutes, tapping the ball in from the rebound after his penalty was saved by Samir Handanovic, and struck again three minutes later to give his side their first league win over their neighbours since January 2016.
Romelu Lukaku pulled one back for Inter in the 29th minute, the first Serie A goal Milan have conceded this season, and had a penalty revoked by VAR for offside in the second half.
Milan have won all four games in Serie A this season and lead with 12 points while Inter have seven after their first defeat.
AC Milan coach Stefano Pioli said he needed Ibrahimovic's prowess on both sides of the field to help the side get the victory.
"He was very tired and asked me for a substitution but I didn't listen to him and he stayed on the pitch until the end," said Pioli. "He is a champion in everything he does, an exemplary professional who always wants to win and his contribution to the team is very important."
Although Milan lead Serie A, Pioli played down title talk.
"There are three or four teams who have invested more than us and are ahead of us on the road to the title," he said.
"We have invested for the long term and we are ambitious. To aim for the title, you have to raise the level of the players and we are doing that. But our journey will take longer than one year. The club has been good at laying the foundations".
His opposite number Antonio Conte was left frustrated at the defeat and returned to one of his favourite themes, saying that Inter had failed to take their chances.
"We're sorry to have lost a game where we played well. Milan were good and I think, also, lucky. We lacked concentration on their two goals," he said.
"In every game, we create so many chances to score goals, but we have to be more clinical in taking them... It's disappointing because the lads certainly put the effort in and believed they could win."
The first half was an end-to-end affair but the pace dropped considerably in the second half as mistakes crept in and the match became increasingly niggly.
Inter had six players unavailable after testing positive for COVID-19 in the last 10 days and others were returning from a hectic week of international football, including three from South America.
Around 1,000 spectators, all invited, were allowed at San Siro.
Ibrahimovic, who returned to training last week after testing positive for COVID-19, made an instant impact as he was fouled by Aleksandar Kolarov and won a penalty. Although his spot kick was saved, he was able to tap in from the rebound.
Three minutes later, Hakan Calhanoglu sent Rafael Leao clear down the left and his inviting cross was calmly turned in by Ibrahimovic at the far post.
Inter quickly got back into the game thanks to Lukaku. Ivan Perisic got free down the left, his low cross caught goalkeeper Gianluigi Donnarumma in no man's land and Lukaku reacted in time to score from close range.
Inter also had the better chances in a much more subdued second half and were awarded a penalty when Lukaku went down under Donnarumma's challenge but VAR ruled that the Belgian was offside in the build-up.
Lukaku was twice close to a stoppage time equaliser as he prodded the ball wide at full stretch and saw a backheeled effort saved by Donnarumma.
Ibrahimovic said it was tough to have to sit out from training as he isolated after he tested positive for coronavirus.
"Your rhythm drops completely, and the body starts to tremble because it wants to train and play," he said. "I was stuck at home for two weeks, it wasn't easy, mentally it's tough especially with the high tempo we had beforehand."
He said he lost some sense of taste but noticed no other symptoms.
"I was being tested every three days to see the result, I told myself I could skip the other games but not the derby. Nobody was going to stop me. We hadn't beaten Inter for four years in the league and I was hungry."
Ibrahimovic said he was disappointed to have a penalty saved even though he followed up and scored from the rebound for Milan's first goal.
"I shouldn't miss a penalty," he said. "The important thing is that the team won. I am the oldest in the squad, I feel a lot of responsibility and I like that feeling as they all follow my lead and are hungry to win."