Nadal, ranked No. 3 in the world, cited physical problems for his decision to skip the Summer Games in London. The Olympic tennis events will be contested at Wimbledon's grass courts where Nadal was a surprise second-round upset victim last month.
"I am not in the right physical condition to compete at the London Olympics and for this reason I will not travel as arranged with the Spanish delegation," Nadal said.
He said his withdrawal would allow "one of my (Spanish) teammates who is better prepared than me take my place and compete to the best of his ability."
Spanish officials had announced that Nadal would be the country's flag-bearer at the Opening Ceremonies in London.
Nadal said: "Today is one of the saddest days in my career. Carrying the flag for Spain at the Opening Ceremony was set to be one of the biggest honors, one of the most special moments for me. For this reason I hope you can understand how difficult it has been for me to take this decision."