Milan were made to battle hard in order to beat Sampdoria 2-1, with Samu Castillejo scoring off the bench and a late scare.
The Serie A leaders had to thank Gianluigi Donnarumma with his early save on Lorenzo Tonelli, then Franck Kessie converted a penalty for handball.
There was a desperate goal-line clearance and Sandro Tonali clipping the upright before Castillejo secured his supersub status by scoring with his first touch.
However, Albin Ekdal flicked on a corner to put Samp back into it and came close to an equaliser in stoppages.