The Bundesliga club announced the acquisition of the 19-year-old on Tuesday, ahead of the league’s kick-off next month.
Hakimi was part of the Real Madrid squad that won the Champions League title, beating Liverpool 3-1.
The Morocco international, who can play at both right-back and on the right of midfield, has been in Real’s youth system since 2006, and made 17 appearances in all competitions last season.
The youngster was also part of the Morocco side that played at the FIFA World Cup in Russia, where they failed to advance from the Group stage.
“Achraf Hakimi is a young, very dynamic full-back, who has played for Real Madrid and the Moroccan national team at the highest level,” BVB sporting director Michael Zorc said of the defender.
Hakimi is now expected to link up with his new team mates ahead of pre-season training in the United States.