Roger Federer will return to world number one after reaching the Mercedes Cup final in Stuttgart, Germany.
The 20-time Grand Slam winner recovered from losing the opening set to beat Australia's Nick Kyrgios 6-7 (2-7) 6-2 7-6 (7-5).
The Swiss, 36, will now overtake Spanish rival Rafael Nadal when the new rankings are released on Monday.
He will face Milos Raonic in Sunday's final after the Canadian beat defending champion Lucas Pouille 6-4 7-6 (7-3).
Victory against the world number 35 will give him a 98th career title.
It is the third time Federer has reached the top of the rankings this season.
He has already achieved 309 weeks at the top of the rankings since February 2004.
Federer was pushed all the way by the fourth-seeded Kyrgios on Saturday, who fired down 23 aces in another battling performance at the German grass court tournament.
Two aces from the 23-year-old forced a first set tiebreak and he quickly built a 3-1 lead after outlasting Federer in a rally.
From that point, Kyrgios ran away with the first set after 42 minutes, meaning the 20-time grand slam champion had a tall order to turn the match in his favour.
However, a double fault from Kyrgios on Federer’s first break point of the second set offered the top seed a way back at 2-1, which Federer extended to a 4-2 lead on serve.
Kyrgios netted a return to concede a double break at 5-2 before Federer completed half his task by taking the match into a third and decisive set.
In a mirror image of the first set, the two players were locked on serve until they were separated by an ultimate tie-breaker.
Kyrgios grabbed a fast 2-0 lead after unleashing a flying forehand pass on the stretch but Federer rallied back to move 5-4 ahead before a flicked effort at the net confirmed his place in the final 6-7 (2-7) 6-2 7-6 (7-5).
“I’m very relieved because I knew it was a tough match against Nick,” said Federer.
“We’ve played so many breakers and it could have gone either way.”
Meanwhile, at the Libema Open in s'Hertogenbosch, Britain's Dominic Inglot claimed his third doubles title of the year.
He and Croatia's Franko Skugor beat South Africa's Raven Klaasen and New Zealand's Michael Venus 7-6 (7-3) 7-5.