Federer ends his career after the upcoming Laver Cup, which is played at the end of September.

“Dear Roger, my friend and rival.

I wish this day had never come.

It's a sad day for me personally and for sports worldwide.

It has been a pleasure, but also an honor and a privilege, to share all these years with you, with so many great moments on and off the court," writes Rafael Nadal, 36, on Twitter.

"We will have many more moments to share in the future, there is still much to do together.

I wish you all happiness together with your wife, your children, your family.

Enjoy what now awaits you”.

Spanish shooting star Carlos Alcaraz, who took home the US Open this weekend:

"Roger has been one of my idols and a source of inspiration.

Thank you for everything you have done for our sport," the 19-year-old writes on Twitter.

Federer has dominated tennis for the past two decades, winning 20 grand slam tournaments and being world number one for 310 weeks, including 237 consecutive weeks.

He is the winner of the most Wimbledon titles with eight trophies.