Clarence Seedorf's side produced an incredible turnaround in the dying moments to snatch victory from the jaws of defeat
The home side looked on course for their first victory over the Rossoneri since 1998 after Marco Sau's clever finish in the 28th minute.
Milan missed a host of chances to equalise but with three minutes left, Balotelli again stepped up for new manager Clarence Seedorf, curling in an excellent free-kick.
The former Manchester City striker scored the winner in Seedorf's first match in charge – a 1-0 Serie A win against Verona – while he also netted in a 2-1 Coppa Italia quarter-final loss to Udinese on Wednesday.
And Pazzini – introduced as a substitute for Robinho on the hour-mark – hooked in Keisuke Honda's corner in the 89th minute, as his first league goal of the season gave Milan three precious points.
The late goals gave the visitors their first back-to-back Serie A wins of the season, as Cagliari's winless run stretched to six matches.
With Christian Abbiati and Andrea Poli the latest Milan players to be struck down by the flu, want-away goalkeeper Marco Amelia made his first appearance of the season.
Cagliari were boosted by Friday's news that striker Mauricio Pinilla had his two-match suspension halved on appeal, allowing him to start, but Colombia forward Victor Ibarbo was still banned.
Amelia made a shaky start, with a mis-kick leading to an early Cagliari chance, but Andrea Cossu's heavy first touch robbed him of a shot on goal, while Robinho curled wide at the other end.
Cagliari then took the lead, against the run of play, after another shoddy Amelia clearance fell to Pinilla.
The Chilean picked out Sau with a chipped ball, and he took it down on his chest before showing excellent composure to wrong-foot Daniele Bonera and calmly slot the game's first goal.
Honda headed at Avramov following an excellent Mattia De Sciglio cross as Milan looked to respond, but their sluggishness at the back was highlighted by Bonera completely missing the ball, allowing Pinilla a shot on goal just before half-time.
Milan improved after the break, as Riccardo Montolivo shot wide just two minutes after the resumption, while Balotelli and Honda shot over, the latter after a clever one-two with Robinho.
But despite their continued chances, Milan could not take advantage, and they were nearly made to pay when Pinilla tried his luck with an angled drive from 18 yards that narrowly missed the top-left corner.
Kaka had a goalbound-header cleared by Davide Astori, but Balotelli's delightful set-piece, after Cagliari substitute Matias Cabrera's deliberate handball, set up a tense finish.
And Pazzini produced the goods for Milan, flicking a late corner into the back of the net to delight his new boss.