Alexandre Pato denied Malaga the chance to seal progression to the last 16 of the Champions League at the San Siro, as the Brazilian striker kept the Rossoneri within touching distance of qualification.
Malaga's perfect debut season on Europe's biggest stage looked set to continue unchecked as Eliseu's first-half goal put the Spaniards on the verge of wrapping up top spot in Group C.
But Pato capitalised on fine work from Kevin Constant to register his first Milan goal since December last year - spoiling Malaga's clean sheet in the competition - to book second place ahead of Anderlecht, who are one point behind the Serie A giants.
Milan suffered an early setback as Ignazio Abate pulled up injured after just six minutes, young full-back Mattia De Sciglio his replacement.
Both sides prodded and poked in the early exchanges, Eliseu failing to properly work Milan keeper Christian Abbiati with a tame shot, before Constant tested Willy Caballero at the other end. But Milan soon turned up the heat, Bojan Krkic thundering into the box to force a fine save from Caballero and Stephan El Shaarawy seeing his dangerous effort deflected behind.
Urby Emanuelson had Caballero at full stretch with a wickedly swerving free-kick after Martin Demichelis' foul on Pato, as Massimiliano Allegri's men exerted their authority.
Indeed, box-to-box man Riccardo Montolivo confidently defused Malaga's intricate build-up play, but Nigel De Jong's less-cultured approach in the 33rd minute earned him the first booking of the evening.
The Rossoneri would pay dearly for a rare moment of ill-discipline, with Isco ensuring the Spanish side made the most of it.
The 20-year-old midfielder weaved through the Rossoneri backline to supply a perfectly-weighted ball for Eliseu, the Portuguese swerving Constant's challenge to beat Abbiati with his right foot.
Milan had been caught cold and Emanuelson's wayward drive over the crossbar was certainly not the clinical response the Italians required before the break.
The Dutchman did warm Caballero's palms with a more accurate strike as play resumed, courtesy of Bojan's cool pass, but El Shaarawy's shot on the turn left much to be desired.
Nerves were frayed on both sides, though, and Emanuelson almost capitalised on a moment of confusion between Caballero and Demichelis.
Kevin-Prince Boateng emerged for the unusually ineffective El Shaarawy shortly after the hour mark, and the ex-Tottenham man introduced himself with an ambitious shot from distance.
Malaga substitute Roque Santa Cruz's first contribution was more impressive, Abbiati tested with a daisycutter, before the Rossoneri finally got their equaliser.
In the 73rd minute, Pato wriggled free in the box to meet Constant's left-wing cross and head home his first goal of the season. Boateng lacked the precision to put Milan ahead moments later, but still the hosts poured forward, and it needed a firm block from Demichelis to deny Montolivo the killer blow.