The striker returned to action after missing two games through injury and opened the scoring before half-time.
Alexandre Pato doubled his team's lead in the 69th minute but then conceded a penalty with two minutes remaining after bringing down Salvatore Masiello.
Bari failed to capitalise as Paulo Barreto's spot-kick was met by a fine save from Milan goalkeeper Christian Abbiati.
The win was Milan's first on the road since January 10 and left them third in the standings, two points behind second-place Roma with a game in hand.
Roma had earlier prevailed 1-0 over Catania while Inter were held to a goalless draw by Sampdoria on Saturday.
Milan went into the encounter looking to bounce back from their 3-2 home reverse to Manchester United in the first leg of their Champions League tie on Tuesday.
The hosts had hoped to avoid their third-straight defeat but really did not pose much of a threat to the Rossoneri.
Milan dominated the opening stages and had the first chance to take the lead in the 13th minute.
Massimo Ambrosini's left-footed strike from the edge of the area went just wide of Bari goalkeeper Jean Francois Gillet's far post.
Shortly after, Pato's central free-kick failed to trouble the keeper.
Bari struggled to break Milan's well-placed defence and the visitors continued to control the game.
On the half-hour mark, Borriello should have broken the deadlock but his powerful header from Daniele Bonera's cross went wide.
But Milan's efforts paid off in the 43rd minute.
Ronaldinho fed Borriello and his left-footed volley from the heart of the area towards the far post beat Gillet.
Bari had the first opportunity shortly after the re-start.
Emmanuel Rivas found Massimo Donati inside the area and his right-footed shot went just wide of Abbiati's far post.
Shortly after the hour mark, Barreto's bullet strike forced Abbiati to palm over the bar for a corner and
it wasn't long before Milan extended their lead.
Gillet parried away Ronaldinho's angled effort but only as far as Pato and the Brazilian made no mistake from close range.
Bari twice had the chance to reduce the arrears but Ferdinando Sforzini nodded wide from the centre of the penalty area before Donati's header from Massiello's cross went inches wide of the far post.
With nine minutes remaining, David Beckham replaced Gennaro Gattuso as Milan looked to finish on a high note.
But it was the hosts that had a chance to re-open the game late on after the referee pointed to the penalty spot when Masiello drew contact from Pato.
Abbiati guessed right as Barreto hit the ball right-footed down the middle of the goal as the keeper came up with the save to preserve the 2-0 win.
Leonardo's Milan will play Fiorentina on Wednesday and a win would lift them over Roma into second place.