The 40-year-old continues to prove he can perform at the top level of football as he netted the landmark goal with a free-kick.
Franck Kessie put Milan 2-0 from the penalty spot after Roma's Roger Ibanez fouled Ibrahimovic.
But there was a tense end to the match as Theo Hernendez was sent off for the visitors, while Stepan El Shaarawy got a goal back late on for Roma.
It meant Milan kept pace with Napoli after their rivals had won earlier in the day.
It was also a landmark defeat for Jose Mourinho as he suffered his first ever loss at home in Serie A.
That run stretched over two-and-a-half years and the Portuguese was none too happy after the game.
"Compliments to Milan," Mourinho told DAZN. "I don't want to say anything else, because otherwise I won't be on the touchline next week.
"I am angry at the lack of respect shown to the Roma fans. We did not play well, but we left everything on the pitch. We have that respect, others do not, and that angers me. That is all."
The 58-year-old also had no time for his post match press conference, and said: "I made an effort and did not wait for the referee."