The Foxes will host the nine-team European champions at Walkers Stadium on July 30, just a week before their season kicks off.
Leicester manager Sven-Goran Eriksson said it will be a great opportunity for the club to test themselves against one of the world's best football sides.
"It is fantastic that Leicester City will be taking on one of the worlds most famous teams," he told the club's official site.
"Real Madrid is a club with great tradition and their squad is filled with world-class players.
"Their manager is someone who demands the best from his players, whatever the occasion, and I am sure it will be an exciting day for our players, and of course, our supporters.
"This fixture shows that the club is growing all the time and emphasises the owners' commitment to moving Leicester City forward."