After a scrappy first half, Milan finally broke Sampdoria's resistance when Franck Kessie scored from a penalty, awarded for handball, in the 45th minute.
Substitute Samu Castillejo appeared to make the game safe for Milan when he rifled in the second for Milan in the 77th minute but Albin Ekdal headed one back five minutes later to set up a nerve-wracking finale for the visitors.
Milan, again missing leading scorer Zlatan Ibrahimovic through injury, have 26 points from 10 games, with Internazionale on 21 and Napoli and titleholders Juventus on 20. Sampdoria are 12th with eleven points.
Milan's starting lineup had an average age of under 23 but managed to overcome opponents who seemed determined to turn the match into a scrap.
"We were missing three important players, but the team has always taken the opportunity, even in negative situations, to show that they are strong, that this is a cohesive group," said Milan coach Stefano Pioli.
"We had a very young team on the field, but they continue to surprise me with their maturity. We didn't let our heads drop when things were going badly and we're not getting carried away now."
However, he still did not see Milan as favourites to win Serie A even though they are five points clear after 10 games.
"How is it possible to think that Juventus are still not the favourites after nine successive titles, or that Inter Milan cannot challenge with investments like such as Achraf Hakimi and Arturo Vidal. But we must continue to grow and improve."