A first-half brace from Ivorian midfielder Franck Kessie is what sealed the points for the visitors, who lost Ricardo Rodriguez to a second yellow card offence, while the hosts' Nicolo Barella suffered the same fate.
Cagliari took the lead with just eight minutes on the clock when Nicolo Barella collected a pass from Artur Ionita and curled a strike beyond Milan goalkeeper Gianluigi Donnarumma and into the bottom corner.
Kessie stepped up and placed the ball past Alessio Cragno from 12 yards to level the match with half time approaching.
Milan, however, took a 2-1 lead into the break thanks to Kessie's second on 42 minutes, which came after the Ivorian had exchanged passes with Kalinic and curled a shot beyond the reach of Cragno.
Both sides attempted to hit the opposition with counter-attacks in the second period and Cagliari's best chance to equalise came in the 75th minute when a deflection saw the ball fall kindly for Fabio Pisacane in the box, but the defender could only direct his strike straight at Donnarumma.
Milan were reduced to 10 men in the 80th minute when Rodriguez picked up his second yellow for clattering into Paolo Farago, but Cagliari did not have much time to make their numerical advantage count.
The hosts went a man down themselves eight minutes later when Barella was penalised for a late tackle on Lucas Biglia, levelling the playing field.
There were five nervy minutes of stoppage time for Milan to navigate, and they almost came undone right at the death, with Leonardo Pavoletti's header from a corner missing the target by mere inches.
Milan held on for the win to move level on points in Serie A with 10th-placed Fiorentina, who have played one match more, while Cagliari remain down in 16th.
CAGLIARI XI: Cragno; Romagna, Ceppitelli, Pisacane; Farago, Barella, Cigarini, Ionita (Deiola '62), Padoin (Cossu '77); Sau (Farias '19); Pavoletti
MILAN XI (4-3-3): Donnarumma; Calabria, Bonucci, Romagnoli, Rodriguez; Kessie (Borini '86), Biglia, Bonaventura (Locatelli '76); Suso (Abate '82), Kalinic, Calhanoglu