The Real Madrid legend has been a revelation in his first season in Serie A.
After the 2-1 triumph, Allegri said: "Apart from his amazing technique, he really wanted to go and take this victory at the end.
"We should all learn from his character and incredible humility. We are so happy to have him here, the younger players must get the most out of working with him."
Milan have now not lost in 23 matches in Serie A.
"This team has technical quality, from time to time we get mentally sluggish, so that's where we still need to step up a gear. The whole season can change in a week, this was our sixth away match out of the last nine," added Allegri.
Milan is in second place in the table, five points behind rival Inter.
