Australian No.1 Nick Kyrgios has lost his showdown with Roger Federer as the Swiss great reclaimed the world No.1 ranking by booking his place in the final of the Stuttgart Open.
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 grasscourt tournament.
Federer, 36, will now overtake Spain's Rafael Nadal when the new ATP rankings are released on Monday.
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."
Federer now goes through to Sunday's final where he will aim for a 98th career title against Canada's Milos Raonic, who won his last title at the 2016 Brisbane International.
Raonic's serve proved the decisive factor yet again as he released 19 aces during his match with defending champion Lucas Pouille earlier on Saturday and he is yet to drop a set in Germany.
"I tried to make it difficult and I don't want any day to be easy for anybody," said Raonic.
"I'm happy I have a chance to come back and play some more good tennis."
Raonic grabbed the opening break of the game with a running forehand down the line before a quick serve and volley tactic sealed the first set advantage.
Frenchman Pouille, 24, kept Raonic at bay on serve, including an enthralling 12-minute trade-off at 3-3, until the pair entered an inevitable second set tie-break.
Raonic edged the baseline and after challenging the original out call had the decision over-turned to open up a 3-1 gap in the tie-breaker.
That gap proved to be the winning margin as another ruthless serve and volley concluded the contest in one hour and 33 minutes.
Going into Sunday's final, Federer has a 10-3 winning record against Raonic, 27, and Federer triumphed in their last meeting at the quarter-final stage of last year's Wimbledon.
"I look up to Federer but I have to come out tomorrow and play my best," Raonic said.