It was an open secret that the Morrocan international was moving to the Italian side. After being spotted in Milan for a medical, the move was imminent.
The deal is believed to be around 40 million euros with Hakimi signing on until 2025 at the San Siro.
He previously spent the last two seasons at Borussia Dortmund, playing 73 times for the Germans and getting 12 goals.
He joined Real Madrid in 2015-16, and went on to make 17 appearances for the first team. His only two goals came against Celta Vigo and Sevilla.
Real Madrid thanked Hakimi by saying “the club want to thank Achraf for all these years of dedication, professionalism and exemplary behaviour since he arrived at our youth academy in 2006 and wish him good luck in his new spell”.