Federer, 34, reached the semi-finals of Wimbledon, where he lost to Milos Raonic, but the 17-time Slam winner underwent surgery on a knee injury in February which forced him to miss the French Open.
It was the first Slam the Swiss great had not competed in since 1998, but his announcement on Tuesday means Federer will not take part in the US Open either, and he will also miss the Olympics, surely ending his hopes of ever winning a singles gold - although he did win doubles gold in Beijing in 2008 alongside Stan Wawrinka.
Federer said that he took the decision in the advice of doctors as he aims to prolong his career for as long as possible.
Nadal turned away by restaurant says Hoy
"Dear Fans," he wrote on his Facebook page, "I’m extremely disappointed to announce that I will not be able to represent Switzerland at the Olympic Games in Rio and that I will also miss the remainder of the season.
"Considering all options after consulting with my doctors and my team, I have made the very difficult decision to call an end to my 2016 season as I need more extensive rehabilitation following my knee surgery earlier this year. The doctors advised that if I want to play on the ATP World Tour injury free for another few years, as I intend to do, I must give both my knee and body the proper time to fully recover."
Federer was a silver medallist at the 2012 London Olympics, losing in the final to home favourite Andy Murray.
Nishikori 'feeling good' ahead of Rogers Cup in Toronto
Murray corrects Inverdale over gender error to earn Sturgeon praise
Majestic Andy Murray completes ‘Super Sunday’