Novak Djokovic returned to No. 1 on Monday after a two-year absence and is assured of becoming the first man in the history of the ATP rankings to finish a season at the top spot after being outside the top 20 during that season.

That's because the man he overtook, Rafael Nadal, is done for 2018. Nadal withdrew from the ATP Finals on Monday, citing an abdominal injury, and announced he was having arthroscopic surgery on his right ankle.

Djokovic will be the ATP's year-ending No. 1 for the fifth time, pulling even with Roger Federer and Jimmy Connors for the second most since the computer rankings began in 1973. Pete Sampras holds the record of six.

"Reflecting on what I've been through in the last year, it's quite a phenomenal achievement," said Djokovic, who was No. 2 last week and hadn't been No. 1 since November 2016. "And, of course, I'm very, very happy and proud about it. Five months ago, if you told me that ... it was highly improbable at that time, considering my ranking and the way I played and felt on the court."

The 31-year-old from Serbia fell to No. 22 in May after beginning the year with a 6-6 record while recovering from surgery on his right elbow. He hadn't been ranked that low since he was 22nd in 2006 as a teenager.

But Djokovic has gone 43-5 since, including Grand Slam titles at Wimbledon and the U.S. Open after reuniting with Marian Vajda, the longtime coach with whom he had split.

Djokovic raised his haul of major trophies to 14, tied with Sampras for third most in men's tennis history behind Federer with 20 and Nadal with 17.

The last man to go from outside the top 20 to No. 1 within a single season was Marat Safin, who was No. 38 and No. 1 in 2000, before ending that year at No. 2.

"What Novak has achieved this season has to go down as one of the great sporting comebacks," ATP Executive Chairman Chris Kerned said. "It's been a phenomenal return to form that would have been hard to imagine just six months ago."

Nadal said on Twitter on Monday that he was still bothered by the stomach muscle issue that forced him to withdraw from last week's Paris Masters. Because he wouldn't be competing at the season-ending tournament in London next week, he opted to have ankle surgery now.

He hasn't competed since he retired from his U.S. Open semifinal against Juan Martin del Potro because of a painful right knee.

The 32-year-old Spaniard ends 2018 with a 45-4 record and five titles, including an 11th French Open championship in June.

John Isner replaces Nadal in the ATP Finals field.

___

Follow Howard Fendrich on Twitter at http://twitter.com/HowardFendrich

___

More AP Tennis: https://www.apnews.com/apf-Tennis and https://twitter.com/AP_Sports