0642 GMT September 26, 2022
The 20-time Grand Slam champion is retiring from the sport after this weekend's Laver Cup in London, BBC Sport reported.
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."
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."
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."
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.