Tennis great Roger Federer withdrew from the French Open ahead of his fourth-round match against Matteo Berrettini, the tournament announced on Sunday.

"After discussions with my team, I've decided I will need to pull out of Roland Garros today," 2009 French Open champion Federer, 39, wrote on Twitter.

Roger Federer
GLYN KIRK/AFP/Getty Images

"After two knee surgeries and over a year of rehabilitation, it's important that I listen to my body and make sure I don't push myself too quickly on my road to recovery. I am thrilled to have gotten three matches under my belt. There is no greater feeling than being back on court," said the winner of 20 Grand Slam men's singles titles.

French Open Tournament Director Guy Forget wished Federer well.

"The Roland Garros tournament is sorry about the withdrawal of Roger Federer, who put up an incredible fight last night. We were all delighted to see Roger back in Paris, where he played three high-level matches. We wish him all the best for the rest of the season," Forget said.

Berrettini advances to his second Grand Slam quarter-final. The Italian will next play world No.1 Novak Djokovic or Italian Lorenzo Musetti.