Massimiliano Allegri's men were pushed all the way by the hosts but a wonder goal from their France centre-half played a key role in them securing a vital win in BrusselsAC Milan ensured their place in the last 16 of the Champions League as they laboured to a 3-1 win over Anderlecht at the Constant Vanden Stock stadium.
The hosts started the game impressively but were unable to make the most of their superior possession due to a lack of creativity in the side.
They were punished early in the second-half when Stephan El Shaarawy put the Rossoneri ahead, and after Bram Nuytinck was shown a red card, Philippe Mexes netted one of the goals of the competition so far to secure the points.
Tom De Sutter did pull one back for the Belgian outfit but Alexandre Pato restored the two-goal cushion in stoppage time.
However, an upset looked entirely possibly earn on, and with 13 minutes gone Milan Jovanovic was released by Dieumerci Mbokani's through-ball. The former Liverpool man had time to pick his spot from the left of the area but his shot lacked pace and was directed straight at Christian Abbiati.
Milan's defence continued to look rather shaky and moments later the hosts had another chance to break the deadlock only for Dennis Praet fired just wide of the post from the edge of the box.
The visitors built upon their great start to the game, penning the Rossoneri back in their own half and enjoying the lion's share of possession.
Despite their dominance, it was not until the 34th minute that Anderlecht came close again. Lucas Biglia's in-swinging free kick was almost turned in at the back post by Mbokani, but Kevin Constant got in between to hook the ball to safety.
Both sides were bereft of creativity throughout the first half, with a lack of goalmouth action making for a stale affair.
However, Milan put a poor opening period behind them as they found the net two minutes after the restart. Mattia De Sciglio's deep cross was controlled exquisitely by El Shaarawy and with his second touch he curled a superbly-placed shot past Silvio Proto.
Anderlecht soon stepped up their search for a goal of their own which lead to the game becoming extremely stretched, but their lack of ingenuity meant chances remained at a premium.
The hosts were regularly hitting a brick wall as they looked to find a route to goal and any hopes of a comeback were extinguished in the space of 60 seconds.
Nuytinck was dismissed in the 70th minute as he took away Pato's legs with the Brazilian ready to go through on goal, but the real hammer blow came from the resultant free kick.
With his back to goal, Mexes controlled the delivery on his chest and improvised magnificently to loop an absolutely stunning overhead kick past an idle Proto from the edge of the box.
John van den Brom brought on De Sutter in the 75th minute as his side had nothing to lose and the change proved beneficial as the striker poked in from close range moments later.
However, as the Paars-wit continued to press they left themselves exposed at the back and Milan took full advantage, as El Shaarawy burst past the defence before sliding the ball across to Pato for a simple finish in stoppage time.
The win ensures Milan will compete in the last 16, while Anderlecht can now only hope for a third-place finish and a spot in the Europa League.