Goals from Stephan El Shaarawy, Philippe Mexes and Alexandre Pato were enough to help Milan put their domestic difficulties behind them with a convincing win over Anderlecht.
Champions League round-up: Troubled AC Milan secure knockout stage progression
Seven-times champions AC Milan put their Serie A problems behind them as Stephan El Shaarawy, Philippe Mexes and Alexandre Pato scored in the second half at Anderlecht to secure their slot in the Champions League last 16.
The highlight came when Frenchman Mexes chested up the ball on the edge of the area and sent a dipping bicycle kick into the far corner of the net to surprise even Milan's unflappable coach Massimiliano Allegri.
"I don't remember what expression I made," Allegri said afterwards.
"Philippe scored a great goal but honestly I thought the ball went over."
Malaga went through as Group C winners despite blowing an early 2-0 lead to draw 2-2 with Zenit St Petersburg in Russia. Diego Buonanotte and Sebastian Fernandez put the Spaniards in front with just nine minutes gone, before Danny and Viktor Fayzulin rescued a point.
Meanwhile Borussia Dortmund guaranteed progression as winners of Manchester City's Group D with Robert Lewandowski scoring twice in a 4-1 thrashing of Ajax at the Amsterdam ArenA.
Marco Reus, Mario Gotze and Lewandowski put the in-form Germans out of sight by half-time, and after Lewandowski had added his second of the night, Danny Hoesen grabbed a consolation for the home side with four minutes left.
Gotze had a hand in the other two goals, but Dortmund coach Juergen Klopp believes the 20-year-old could have contributed even more.
"Mario played exceptionally but also like we know he can play," Klopp said after the match.
"But he could have done better in finishing."
Porto and Paris St Germain will play off in Paris next month to determine the winners of Group A after both sides underlined their progression to the knockout stages with easy wins tonight.
Porto remain a point clear at the top of the group after a 3-0 home win over pointless Dinamo Zagreb, Lucho Gonzalez putting them ahead in the 20th minute before second-half strikes from Joao Moutinho and Silvestre Varela.
And the French side also rubber-stamped their qualification with a 2-0 win over Dynamo Kiev in Ukraine, with Ezequiel Lavezzi opening the scoring on the stroke of half-time and adding a second soon after the break.
Christian Fuchs scored the only goal of the game in the 77th minute as Schalke 04 beat Olympiakos to ensure qualification from Group B and give them a one-point advantage over second-placed Arsenal going into the final round of fixtures
Follow us @SprtNationalUAE