roger federer
Roger Federer reached the semi-final stage in the Wimbledon championshipsGetty

Roger Federer has surprised fans by announcing he will miss the rest of the 2016 season and miss the 2016 Olympic Games in Rio because of ongoing knee problems.

Federer has suffered an injury-hit season but appeared to be back at near his best in reaching the Wimbledon semi-finals at the age of 34. There, he lost to Milos Raonic, his first ever defeat at the semi-final stage at SW19.

Federer missed much of the early part of the year after having knee surgery in February having slipped in the bathroom while running a bath for his twin girls. He made a tentative comeback in April but missed the French Open entirely, concentrating instead on the short grass-court season. He reached the semi-finals in both Halle and Wimbledon, and appeared to be regaining his form and confidence ahead of the hard-court season and the Olympics in the autumn.

However, on his Facebook page he told fans he was pulling out of Rio and the rest of the season, including the US Open and the end-of-season ATP World Finals at the O2 Arena in London, which features the top eight players of the season.

The Swiss said he was "extremely disappointed", but explained: "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. It is tough to miss the rest of the year."

Federer, who has 17 grand slam titles but no tournament wins this year, claimed: "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."