The 17-times Grand Slam winner returned to the pinnacle of the rankings after a two-year absence by beating Britain's Andy Murray in the Wimbledon final last week.
It was the 30-year-old Swiss's seventh title at the All England Club and ensured he would equal and then pass Pete Sampras's record of 286 weeks at the top of the rankings.
"I am extremely proud and honoured to have beaten Pete's record as he was my childhood hero and I have always looked up to him," said Federer, who first topped the rankings in February 2004.
"I had set a goal with my team to try and get back to the top of the rankings, but I never thought with the depth in the game this year that I would have been able to get it back so quickly."
Sampras won 14 grand slam titles in a 14-year tour career.
"The hardest thing to do in sports is the ability to stay on top," the American said.
"Roger has been able to do so by great play and durability."