Milan edges past Atalanta
The prodigiously talented striker had gone missing over recent games, having provided Milan's biggest threat in the first half of the season, but his clinical finish gave the visitors the lead at the Stadio Atleti Azzurri d'Italia.
Atalanta refused to surrender, though, and their bid for a first win in six games only unraveled when Davide Brivio was sent off for picking up two yellow cards in the second half.
From that point on Milan might have run riot, but they failed to capitalize on a host of gilt-edged chances as time ticked away.
Mathieu Flamini made Milan's intentions clear with a fierce strike from distance in the fourth minute, but Andrea Consigli parried the ball to safety.
Atalanta have proved to be dangerous on the break this season and Facundo Parra was desperately unlucky not to convert German Denis' fine slide-rule pass in front of Christian Abbiati.
El Shaarawy showed his worth on the counter-attack too, almost beating Brivio into the box before another penetrative run was ended by the imposing Guglielmo Stendardo.
But the young striker's 17th goal of the season would come in the 29th minute.
French striker M'Baye Niang, who excelled in Milan's win at Bologna, tricked his way up the right wing to find El Shaarawy lurking, the 20-year-old gratefully tucking the ball beyond Consigli.
Atalanta's resolve might well have faded at that point but the Nerazzurri continued to surge forward, Abbiati foiling a dangerous move between Denis and Giacomo Bonaventura.
Niang's daisy-cutter sent Consigli sprawling moments later but Milan would carry the narrowest of margins into the break.
Flamini failed to make the most of another incisive ball from Niang as play resumed, with Stendardo soon scrambling the ball away from Giampaolo Pazzini's quick feet.
Blows were exchanged towards the hour mark as Consigli pushed a Pazzini backheel away from danger. At the other end, Parra held the ball up to release Denis in the area, but Abbiati leapt off his line to rescue a corner.
The odds tipped in Milan's favor when Brivio, who had been booked shortly after the restart, picked up a second yellow card and his marching orders.
Atalanta did not lose heart and influential midfielder Carlos Carmona soon put his body on the line to cut out a vicious finish from Flamini.
Rather than exploit the space, Milan began to waste decent chances, Riccardo Montolivo fluffing a close-range effort before Flamini scooped the ball away from an open goal.
The match was degenerating fast and, with time running out, Atalanta boss Colantuono was sent to the stands for continually protesting referee Andrea Gervasoni's decisions.