The 21-year-old Moroccan spent the last two seasons at Borussia Dortmund and was expected to return to his parent club this summer, but Los Blancos have taken the opportunity to sell the player who would likely not have been first choice under coach Zinedine Zidane.
"Real Madrid C. F. and Inter Milan have reached an agreement over the transfer of Achraf Hakimi," the Spanish side said on their website.
"The club wishes to thank Achraf for his many years of dedication, professionalism and exemplary conduct since he joined our academy in 2006 and wishes him all the very best in this new chapter."
Achraf has signed a five-year deal with Inter and Madrid will have an option to buy back the player if he leaves the Italian giants at any point in that period.
During his time at Real, Hakimi made 17 appearances and scored two goals.