USA TODAY Sports

Roger Federer announced he's out for the rest of the season and will miss the upcoming Rio Olympics.

In a statement on his Facebook page, Federer said he's "extremely disappointed" that he won't be representing Switzerland in the Summer Games, which begin Aug. 5.

"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," Federer wrote. "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. It is tough to miss the rest of the year.

"However, the silver lining is that this experience has made me realize how lucky I have been throughout my career with very few injuries. The love I have for tennis, the competition, tournaments and of course you, the fans remains intact. I am as motivated as ever and plan to put all my energy towards coming back strong, healthy and in shape to play attacking tennis in 2017."

Federer, 34, reached the semifinals at Wimbledon earlier this month, falling to Milos Raonic in five sets and ending his run at an eighth title at Wimbledon. It was the first time he had lost in the semifinals of that tournament. It appeared he tweaked his knee in an awkward fall late in the match.

He said at Wimbledon that he fully expected to be back.

"Yes, I hope to be back on Centre Court, to be very clear for you," he said.

Federer will miss the U.S. Open, where he is a five-time champion, for the first time since 1999.

He was expected to compete in his fifth Olympics, playing singles and with Stan Wawrinka in doubles. In 2008, the two won gold in Beijing. Federer claimed the silver in singles at the 2012 London Olympics.