Both Nadal and Djokovic, both known to be Real Madrid supporters, aim to raise money for Nadal's charitable foundation, which helps alleviate child poverty.
Roger Federer was originally invited to battle with the Spaniard but the Swiss ace declined the offer due to the match being scheduled in between Wimbledon and the Olympics.
Nadal expressed his delight about the game by posting a short message on his Facebook page on Tuesday.
The world number two said: "Good morning! Back to practicing very happy because the Rafa Nadal Foundation's event has been confirmed at Bernabeu!"
The game is expected to attract 80,000 people, which would shatter the previous record attendance for a tennis match of 35,681 who watched Serena Williams and Kim Clijsters in Brussels in July 2010.