Milan earned their first win of this season's Champions League group stage, but were made to work for it by Dinamo Zagreb as the Italian champions secured a 3-1 victory at San Siro.
Goals either side of half-time from Olivier Giroud and Alexis Saelemaekers gave Stefano Pioli's men a strong lead.
They were made to sweat after Mislav Orsic – who scored the winner against Chelsea for Dinamo last week – pulled his team within one goal again with a fine finish just before the hour mark.
The Rossoneri appeared to tire in the closing stages of the game, but sealed the points when substitute Tommaso Pobega swept in a third for Milan's first home win in the Champions League since they beat Celtic in September 2013.
Milan made the early running, with Sandro Tonali and Giroud seeing early efforts sail over the crossbar, while Ismael Bennacer and Saelemaekers had shots from range easily saved by Dominik Livakovic.
A rare moment of panic from an otherwise organised Dinamo cost them when Josip Sutalo kicked through the back of Leao as he tried to intercept a pass into the area, and the referee pointed to the spot, with Giroud calmly sending Livakovic the wrong way from 12 yards, putting his penalty to the goalkeeper's left to give Milan the lead just before the break.
It did not take long in the second half for Pioli's side to double their advantage, with Leao working space down the left before standing up a cross for Saelemaekers to head in from close range for his second goal in two group stage games this season.
The game was not done though, with the dangerous Orsic playing a neat one-two with Bruno Petkovic, cutting through the Milan defence before the former placed his shot into the far corner of the net to halve the deficit.
Pobega finished well to clinch it after 77 minutes, hitting a first-time shot from Theo Hernandez's cut back in off the bar as Milan move on to four points in Group E from their first two games, a point ahead of Dinamo.
What does it mean? Milan finally end poor San Siro record
As mentioned, this was Milan's first home win in the Champions League since September 2013, ending their longest run without a home victory in the competition.
They had played six games at San Siro in the Champions League since then, drawing three and losing three, and lost on home soil against both Atletico Madrid and Liverpool last season.
In a potentially tough game and with a double-header against Chelsea on the horizon, it was vital they ended that run against their Croatian opponents, and they did just that with a hard-working performance.
Giroud leads from the front
The former Arsenal striker has his detractors, but this was a solid showing from Giroud, scoring his penalty with ease to give Milan the lead.
He took four shots, as many as anyone, with three hitting the target before his withdrawal in the 68th minute for Charles de Ketelaere.
Orsic Dinamo's only hope
Orsic's goal was his sixth in eight Champions League appearances. He is Dinamo's leading scorer in major European competition, scoring 19 goals in 38 appearances in Champions League and Europa League.
The problem for Ante Cacic is Orsic appears to be his only hope of scoring, with the 29-year-old taking three shots, and no other Dinamo player having more than one, while his strike partner Petkovic did not register any.
Key Opta Facts
Aged 35 years and 349 days, Giroud's penalty has made him the second-oldest French player to score in the Champions League, after only Laurent Blanc for Manchester United in 2002 (36y 338d).
Saelemaekers is the first Milan player to score on the first two matchdays of a Champions League season since Zlatan Ibrahimovic in 2010-11.
Pobega is the first Italian scorer for Milan in the Champions League since Mario Balotelli in November 2013 against Celtic.
Prior to Pobega's goal, the last goal scored at home by an Italian Milan player in the Champions League was in September 2011, courtesy of Antonio Cassano against Viktoria Plzen.
Milan host Napoli in Serie A on Sunday, while Dinamo have a derby trip to Lokomotiva Zagreb in the HNL the same day.