The 21-year-old has been on loan at Borussia Dortmund for the past two seasons and excelled in the Bundesliga, clocking up five goals and 10 assists this season.
He now moves to Serie A, with Sky in Italy reporting the deal would be worth around £36 million (€40m).
Inter confirmed the move on their website on Thursday.
“Achraf Hakimi is offically an Inter player,” a short statement said.
“The Moroccan, who was born in 1998, has joined the Nerazzurri on a permanent basis from Real Madrid and has signed a contract which will last until 30 June 2025.”
Manager Antonio Conte has almost exclusively used wing-backs this season as he seeks to take Inter back to the top of Italian football, with Victor Moses and Ashley Young among his signings this season in the role.
Real Madrid have Dani Carvajal as their regular right-back option, while Alvaro Odriozola will return as backup in the position following the end of his own loan at Bayern Munich.
Hakimi was born in Madrid but represents Morocco at international level, where he has 28 caps so far.