Scamacca's 68th-minute own goal put second-placed Milan eight points behind city rivals Inter, who travelled to Napoli later on Sunday, and kept them on course for a return to Champions League football next season.
Stefano Pioli's side had not won their last six games in the San Siro in all competitions and were playing without suspended forward Zlatan Ibrahimovic.
"We wasted a lot, we could have finished it earlier, but the important thing is the spirit to stay in the game until the very end," said Pioli, who has given up on catching Inter. "Inter have taken too many points to think that we can still fight for the Scudetto (league title). We will have to face important teams, Atalanta, Juventus, Lazio, from here to the end they will all be difficult."