The visitors frustrated Milan for large spells at the San Siro and looked lively on the counter through Alessio Cerci.
Migjen Basha then flashed an inviting cross into the penalty area, but no Torino player was able to take advantage at the far post.
Milan rallied after the break, with Robinho going close late on after beating three defenders in a slalom run towards goal.
Barreto then failed to turn home once more from inside the six-yard box, with Torino made to pay for their missed chances in the closing stages.
With time running out for the Rossoneri, a cross from Antonio Nocerino was flicked on towards Balotelli, who made no mistake to tap home from point-blank range.
The three points mean that Massimiliano Allegri's side are now four points clear of Fiorentina in the race for third place in Serie A, with Torino still locked in a fight to secure safety at the other end.