Tennis legend Roger Federer announced on Thursday that he is retiring from sport after next week's Laver Cup, putting an end to a long and storied career.

The 20-time Grand Slam title winner has not competed since Wimbledon in July 2021.

"As many of you know, the past three years have presented me with challenges in the form of injuries and surgeries," Federer wrote in a statement. "I've worked hard to return to full competitive form. But I also know my body's capacities and limits, and its message to me lately has been clear."

"I am 41 years old. I have played more than 1500 matches over 24 years. Tennis has treated me more generously than I ever would have dreamt, and now I must recognize when it is time to end my competitive career," he added.

Federer had appeared at an event marking the 100-year anniversary of Centre Court at the All England Club this July and said he hoped to come back to play there "one more time."

He also had said he would return to tournament action at the Swiss Indoors in October.

Federer's last match anywhere came on July 7, 2021, when he lost at Centre Court in the Wimbledon quarterfinals to Hubert Hurkacz 6-3, 7-6 (4), 6-0.

Soon after, Federer had surgery to repair damage to his meniscus and cartilage in his right knee — his third operation on that knee in a span of 1 1/2 years.

This is a breaking news story. Check back later for updates.