The Italy striker only returned to the team in December following a long injury lay-off and, minutes after Mario Balotelli cancelled out Marco Sau's first-half opener with a free-kick, Pazzini was on hand to knock home from a corner.
It was a second straight league victory for Milan under new coach Clarence Seedorf and, although 14th-placed Cagliari may feel sick after surrendering all three points, the mainlanders can celebrate climbing two places to ninth.
Cagliari started brightly as Andrea Cossu took the ball under control in the visitors' area. He was too slow to get his shot off, though, and goalkeeper Marco Amelia won the battle of wills.
Milan were soon up the other end to test Vlada Avramov through Robinho and Keisuke Honda's backheel almost led to an opening goal from Balotelli.
Avramov saved again and did well to repel another Balotelli shot when the Italy striker burst in to the area in the 16th minute.
The Cagliari keeper then got gloves to an angled drive from Honda, who had been set up by Balotelli, and he watched anxiously as Kaka fell over his own feet in a shooting position.
In the 28th minute, against the run of play, Cagliari took the lead.
Amelia was to blame as he pushed Mauricio Pinilla's tame shot onto Sau's feet, the Sardinian rounding defender Daniele Bonera with ease to clip home.
Milan's response was tame before the break as Robinho wasted a free-kick from a good position - Riccardo Montolivo made a mess of the follow-up - and there was no excusing Honda as he headed into Avramov's hands from two yards out.
The Rossoneri continued to dominate without putting their chances away when play resumed and Balotelli was wasteful once again in the 54th minute, pinging Kaka's cute pass high over the bar.
A fine exchange of passes between Honda and Robinho saw the Japanese clip narrowly over from the D and an innocuous shot from Mattia De Sciglio caused Avramov few problems.
Cagliari had been happy to sit on their lead while Milan toiled in vain but came dangerously close to extending their lead in the 73rd minute as Pinilla fizzed a shot just past a post with Amelia rooted to the spot.
By this point Milan were looking short on ideas and when Davide Astori stopped Kaka shooting from close range, their race appeared to be run.
But, after Matias Cabrera conceded a free-kick on the edge of the area in the 82nd minute, Balotelli stepped up to guide the ball between Avramov and a post.
That single moment galvanised Milan and, to the horror of the Stadio Sant'Elia faithful, Pazzini - a replacement for Robinho - turned the game on its head right at the death.
The striker who had only just recovered from a thigh injury in time to make the trip to Sardinia, swung his leg at Honda's corner to snatch another league win for Seedorf's men.