The 19-year-old striker scored two goals in 22 appearances for the Rossoneri last season after signing from Genoa in June 2011.
A statement on acmilan.com read: "AC Milan can announce that Stephan El Shaarawy's contract has been extended until June 30 2017."
On Wednesday morning Milan vice-president Adriano Galliani confirmed his interest in bringing Real Madrid playmaker Kaka, whose future at the Santiago Bernabeu remains uncertain, back to the club where he made his name.
He told the Gazzetta dello Sport: "Some loves never end, they may go away for a long time, but they always return."
And on Wednesday night El Shaarawy told gazzetta.it: "I'm happy to have re-signed.
"Next year I hope to do well, to do better. I hope to have the chance to play in more space.
"Becoming a team-mate of Kaka would be a dream, he's always been my idol."