The off-form Scottish champions had already been knocked out of the competition by the time they travelled to Italy but they stunned the home side with goals from Tom Rogic and Odsonne Edouard in the first 13 minutes.
Norwegian attacker Jens Petter Hauge scored a fine third five minutes after the interval and in the 82nd minute Milan substitute Brahim Diaz added a fourth to leave the Parkhead side with one point from five Group H games.
Celtic chief executive Peter Lawwell gave his backing to his under-fire
manager Neil Lennon after hundreds of fans turned up at Parkhead to vent their fury after the Betfred Cup defeat to Ross County on Sunday.
Those supporters will not be encouraged with this performance as Celtic look at two wins in their last 11 matches in all competitions.
Rogic gave Celtic the lead in the seventh minute when he capitalised on slackness from home defender Rade Krunic to curl in a shot in from the edge of the box.
The Australia international came close again two minutes with an effort from the same distance which whistled past the post before injured Milan defender Simon Kjaer was replaced by Alessio Romagnoli.
It was looking good for Lennon's side.
McGregor then tested keeper Gianluigi Donnarumma with a drive from 10 yards moments later after good work by Frimpong before the Scottish champions doubled their lead.
Midfielder Ryan Christie played in French striker Edouard and he almost casually dinked the ball over Donnarumma.
AC Milan were clearly rattled but then came the Celtic collapse.
Christie conceded a free-kick just outside the box in the 23rd minute and Calhanoglu bent in his free-kick with Celtic keeper Vasilis Barkas flatfooted.
Three minutes later Milan wide man Hauge raced in to the box and when his cross broke to Castillejo he swept in the leveller from eight yards.
AC Milan now had the upper hand but Celtic steadied themselves and McGregor had a decent shot saved by Donnarumma just before the interval.
The Parkhad side were on the back foot at the start of the second half and fell behind when Hauge weaved his way into the box past McGregor, Hatem Elhamed and Frimpong and curled a shot past Barkas into the corner of the net.
Milan had a firm grip of the game but just on the hour mark Frimpong dragged a shot wide from a good position after being set up by Nir Bitton.
Then Donnarumma pulled off a fine save in the 72nd minute from Christie's 25-yard free-kick.
But with eight minutes remaining, Diaz, on for Hakan Calhanoglu in the 60th minute, added a fourth when he lifted a pass from Hauge, who got past Elhamed far too easily, over Hoops keeper Barkas from close range to complete another dismal night in Europe for the Scottish champions.