The 36-year-old Swiss overcame an early setback to beat Robin Haase of the Netherlands 4-6, 6-1, 6-1 and will replace old rival Rafael Nadal at the top of the rankings.
"What an amazing run it's been, to be number one again means a lot to me," Federer said.
"This is incredibly special, I'm so happy. I didn't really think I could get back to number one, this is a significant moment in my career."
Federer surpasses Andre Agassi, who held the top spot aged 33 years and 131 days in 2003, as the oldest man to claim the world number one spot.
It is Federer's first time back at the summit since October 2012 having first claimed the top position in February 2004.
"Reaching number one is the ultimate achievement in tennis. When you're older you have to work double the amount, you have to wrestle it back from someone who's also worked hard to get there. It's a dream come true," added an emotional Federer.
"It's been an amazing journey and to clinch it here, where I got my first wildcard in 1998, means so much."
Agassi was amongst the first to congratulate Federer.
"36 years 195 days... @rogerfederer continues to raise the bar in our sport. Congratulations on yet another remarkable achievement!!," tweeted the American.
Federer had talked on Thursday of his desire to retake the world number one spot but doubted it would ever happen after he underwent knee surgery last year.
"I've struggled to try and get there. I had to win a lot of matches last year," said Federer, who was as low as 17 in the world in January 2017 before he returned to form with the Australian Open title.
The ageless wonder dropped his first set of the week against Haase, who later said he had been sick all week and unable to do any more than play his matches.
Federer is back on top after winning three majors in 13 months, including another Australian Open in January.
- 'Double nice at my age' -
Federer was on his heels in the opening set as the aggressive Haase prevailed, but the Swiss top seed regained control to ease to the victory as he controlled the Dutchman in the remainder of the contest.
The Swiss triumphed to the cheers of the fans in 79 minutes, ending with six aces. Haase finished on a disappointing note with his second double-fault on match point.
Federer will now face a decision whether to try and stretch his leading margin over Nadal by competing in just over a week in Dubai, his Gulf training base.
"To rank this high, I don't know how I did it. This is really big for me, especially because of the gap (between his last time at the top).
"It's double as nice at my age to be number one, there is a lot that goes into it."
Despite his achievement, Federer still has a semi-final to play on Saturday.
"I hope all this is not a distraction, it may or may not be. I came here to get to number one and then win the tournament.
"But I've got all day tomorrow to recalibrate. This could also free me up, lay the pressure aside and start to play my best tennis."
Second seed Grigor Dimitrov edged towards a possible first final in Rotterdam as he dispatched young Russian Andrey Rublev 6-3, 6-4 to reach the semi-finals.
Sixth seed Tomas Berdych withdrew prior to his quarter-final, with the Czech's absence putting fourth seed David Goffin into the semi-finals.