The Swede gave the visitors the lead at the Stadio Olimpico and then added the decisive third.
Alessandro Nesta scored Milan's other goal while Nicolas Burdisso and Bojan
Krkic replied for Roma.
"Tonight he (Ibrahimovic) was excellent, he had an amazing game, as did (goalkeeper Christian) Abbiati who played very well and in some situations, like at 2-1, made important saves," said Allegri.
"It's a great win against a team that will do very well in the league, they will fight for the title as well as the other six.
"We had few worrying moments, we missed some chances and we conceded a goal
at the end and that kept the game in suspense until the end of injury time."
Allegri was also pleased to see his team closing in on top spot.
They actually led the table ahead of the late match between Inter Milan and Juventus as well as Sunday's matches.
Three teams can still overtake them with a victory while of those Juve can also do so with a draw.
"We're closing in on top spot and we'll just wait for the Udinese, Lazio and Inter-Juve games," said Allegri.
"It was important for us to get some results because we've won our first direct clash (between title rivals) this season given that we'd already lost two (against Juve and Napoli)."