Roger Federer
Roger Federer thought his surgery in 2016 would lead to the end of his career Getty

Roger Federer has revealed that getting surgery last year made him think his career was ending once and for all.

The Swiss ace suffered a knee injury a day after his 2016 Australian Open semi-final loss to Novak Djokovic which resulted in Federer requiring surgery.

Needing arthroscopic surgery to repair a torn meniscus in his knee, Federer, who was getting surgery for the first time in his career, started to fear the worst.

"The moment I went into surgery was a scary moment for me because I'd never had surgery before," Federer told Standard Sport.

"The moment I woke up from surgery, looking down on my knee and going, 'Oh my God, I have an operated knee', I didn't know if I was ever going to come back from this."

The 36-year-old even went as far as accepting it would be the end of his career. He said he was realistically ready for retirement all the way back in 2009 when he achieved a career slam by winning the French Open for the first time.

"I was okay with the idea of it all ending," Federer explained. "You know, maybe as far ago as winning Wimbledon for the first time in 2003 I was okay if it all ended."

"I know it sounds strange but I'd achieved my lifelong dream of winning a Wimbledon title. But really, ever since Paris in 2009, I was totally at peace with it ending the next day."

Instead of retirement, Federer came back and decided in July that he would take the rest of the year off to completely heal his knee which has more than paid dividends.

The world number two has experienced a career resurgence in 2017, winning a total of seven titles which includes the Australian Open and a record-breaking 10th Wimbledon crown — his first Grand Slams since 2012.

Federer is also currently in the last four of the ATP Finals in London as he seeks to end his remarkable season on a high.