Federer withdraws from Tokyo Olympics after knee injury 'setback'
The 20-time Grand Slam champion was knocked out of Wimbledon in the quarter-finals by Hubert Hurkacz last week.
The 39-year-old Federer, who has never won an Olympic singles gold medal, underwent two surgeries on his right knee in 2020.
The tennis competitions in Japan are set to start on July 24, the day after the opening ceremony.
Federer, who turns 40 next month, pulled out of the French Open after reaching the fourth round, hoping to get fit for Wimbledon.
He showed signs of his best during his run to the quarter-finals, but bowed out tamely, losing 6-3, 7-6 (7/4), 6-0 to Poland's Hurkacz.
That defeat sparked talk among fans and pundits speculating whether the eight-time Wimbledon winner would retire, with Federer saying he "didn't know" if his Wimbledon career was over.
But on Tuesday, the former world number one said he was hoping to return to the ATP Tour later this summer.
"I have already begun rehabilitation in the hopes of returning to the tour later this summer," he added.
"I wish the entire Swiss team the best of luck and I will be rooting hard for the team from afar."