"My right knee has been bothering me for a little while," he said.
"I hoped it would go away, but after an examination, and discussion with my team, I decided to have arthroscopic surgery in Switzerland yesterday.
"After the procedure the doctors confirmed that it was the right thing to have done and are very confident of a full recovery.
"As a result I will unfortunately have to miss Dubai, Indian Wells, Bogota, Miami and the French Open. I am grateful for everyone's support. I can't wait to be back playing again soon, see you on the grass!"
Federer returned to play Roland Garros in 2019 where he made it through to the semi-finals, but skipped the clay court seasons in 2018 and 2017 to keep his body fresh for Wimbledon.
He is coming off a charity promotion event in South Africa and an Australian Open campaign where he admitted his body felt "horrible" during his semi-final loss to Novak Djokovic.
Despite physically struggling at Melbourne Park, Federer showed no signs of knee issues when he played Rafael Nadal in Cape Town earlier this month. The outdoor exhibition match, watched by 51,954 fans, set a world record for the most watched tennis match in history.
Federer revealed during the Australian Open he was close to pulling the pin on his semi-final blockbuster against Djokovic where he played through grimacing pain.
Having been on the ATP Tour for more than 20 years, Federer carries a near unprecedented record of never retiring from a match.
Federer was coming off two five-set marathon wins over John Millman and Tennys Sandgren. He also appeared to suffer tightness in his legs during the match against Sandgren, calling for a medical time out in both of his final two matches at the Open.
He said it hurt him to play wounded — especially after it soon sunk in that he was almost no chance of beating Djokovic.
"Today was horrible, to go through what I did," he said.
"Nice entrance, nice send-off, and in between is one to forget because you know you have a three per cent chance to win. You know, got to go for it. You never know. But once you can see it coming, that it's not going to work anymore, it's tough.
"I've been there before. I've had a few matches throughout my career where I've felt that way."