Roger Federer says his decision to retire came after he "stopped believing" he could continue playing because of injuries.
The 20-time Grand Slam champion is retiring from the sport after this weekend's Laver Cup in London.
The Swiss, 41, has not played since Wimbledon 2021, after which he had a third knee operation.
"The last three years have been tough to say the least," he told BBC Breakfast.
"I knew I was on very thin ice for the last year ever since I played Wimbledon.
"I tried to come back but there was a limit to what I could do. And I stopped believing in it, to be honest."
Federer said he had a scan a few months ago and it was "not what I was hoping for", adding: "Very quickly we realised this was it.
"Then the question becomes: how do you announce and when do you announce? This is when it becomes reality. It was OK but stressful."
In a wide-ranging interview with Sally Nugent, Federer discussed his emotional retirement statement, reflected on his trophy-laden career, looked at what's next for him and offered his memories of the late Queen.
'Writing those words was like rehab'
The eight-time Wimbledon champion announced his retirement last Thursday in a statement on social media.
"It's been an emotional few weeks to go through those words to try to get them right, that they reflect how I'm feeling and thanking all the people who have helped along the way," he said.
"I always pushed my retirement thoughts away. I said, the more I think about it, the more I'm already halfway retired and this is not the way to go to work, you know, for me as a tennis player, so we'll deal with it when it comes. And it did. And I dealt with it.
"I think writing those words was, for me parts, partially also like, rehab, like going myself through all those words, feeling them."
'I totally overachieved in my mind'
Now regarded as an all-time great, Federer says he never went into tennis imagining he would have such success - and having achieved so much, he was now happy to step away.
He spent 310 weeks as world number one - including a record 237-week consecutive stint - and won 103 ATP singles titles.
"I don't think anybody grows up and thinks they're gonna win this much," said Federer. "You know, you're happy with winning a Wimbledon title, which is already crazy, or becoming number one, being the best.
"But then you don't think how many weeks, this is only the media and the fans talking about breaking records.
"Before it was just, I hope to be on tour one day. Just to make it into the top 100 is a huge deal. Coming from a small country, we don't have a base of so many players.
"I totally overachieved in my mind. It's been an absolute dream that I've had for so long. And I know that, and that's why I'm totally happy to step away as well."
'It's been a joy to watch'
Federer has played in an era where he, Rafael Nadal, Novak Djokovic and Andy Murray were dominant across the major tournaments.
The four men will be on the same team at the Laver Cup between 23 and 26 September, a Ryder Cup-style tournament in which Team Europe takes on Team World.
Federer, Djokovic, Nadal and Murray will line up for Europe alongside Casper Ruud and Stefanos Tsitsipas, in what will be the Swiss' final professional competition.
He is happy his era has thrilled tennis fans, but does not believe they have to worry about the future of the sport now it is ending.
Federer said: "When I came up, we didn't expect it either. You know, we were more on a bit of a downslope after [Pete] Sampras retired. What's gonna come next, right? Well, here I came, and then came Rafa. And then there was Novak, and then Andy, all together.
"All of a sudden, there was this beautiful mix, we're all winning for 10 plus years, all the same tournaments, almost nobody else could win anything else. It was like a lock on the big tournaments.
"So I think, also for the fans, it's been a joy to watch, and I'm sure some fans will be sad I'm leaving, of course, but then again, there will always be wonderful new people.
"I think our tour allows for incredible storytelling so that's why I know that the game is very safe, and I'm sure it will see incredible new superstars."
Finding a new Swiss superstar
Federer says he has not made specific plans for his retirement, but would like to stay in tennis and hinted he would be interested in youth coaching to bring through the next generation of talent in Switzerland.
However, Federer first plans on spending more time with his wife, Mirka, and their four children.
He said: "I always tried to keep a clean slate for when I retire, because I do have four children and they're amazing and they need my help. And my wife, too, she's always been by my side throughout. So it's a little bit let's see what they all want to do and what we should do.
"I would love to always mentor the children and get a new Swiss superstar going. If I can help the federation a little bit here and there, you know, I can see those things.
"But I still have to figure things out a little bit. I'll go home after this. And then we have vacation soon after that with the children. So I think it'll be a nice time to reflect and look forward."
He added: "I love this game and I want to stay involved in some shape or form. I won't be a ghost or some stranger."
Memories of the Queen
Having enjoyed some of the greatest moments of his career in the UK, Federer was deeply moved by the scenes on Monday during the state funeral of Queen Elizabeth II.
He fondly recalled meeting the Queen on her last visit to Wimbledon in 2010, 33 years after she had previously attended, and praised the Royal Family's support for tennis.
Federer said: "I had the chance to eat lunch with her at Wimbledon when she came back finally to Wimbledon, after giving the trophy to Virginia Wade [in 1977].
"Everybody at the tennis was so happy she came and I was lucky enough to meet her. I will remember that forever."