The Cherries, who finished second in League One last season, welcome Carlo Ancelotti's side to Dean Court on July 21.
"Real Madrid are at the pinnacle of global sport and to host them will be an honour for the squad, management and supporters of AFC Bournemouth," chairman Eddie Mitchell told the club's official website.
"We see the fixture as a well-earned gift to our fans for their unwavering dedication to AFC Bournemouth, and also an opportunity for us to put the town of Bournemouth on the map.
"We are honoured to have been handpicked by Real Madrid to be their hosts in this landmark moment for the Football League, and we will do everything to ensure the game goes down in history."
The match on the south coast sees the nine-time European champions kick-off their pre-season campaign ahead of a trip to the USA to compete in the International Champions Cup.
Emilio Butragueno, Real Madrid's director of institutional relations, added: "The friendly match will be a fantastic opportunity for both teams and we are looking forward to travelling to Bournemouth and to the Goldsands Stadium.
"We look forward the challenge presented to us by our English opponents."