Regardless of the result on Sunday, Federer will reclaim the No. 1 ranking from Rafael Nadal next week.
Raonic, from Thornhill, Ont., won his last title at the 2016 Brisbane International.
The Swiss, who holds 20 Grand Slam singles titles, needed to go all the way against the Austraian Kyrgios, playing his first event in two months due to injury.
The Swiss star has a 10-3 in career head-to-head meetings against the Canadian.More news: Bannon Urges Trump to Shut Down Government if No Wall
Raonic gained the upperhand when he was able to steal a point to gain a 3-1 lead in that tiebreak.
The heavy crowd favourite at the Weissenhof Club earned a match point with a high overhead backhand victor and finished off the popular victory seconds later to the roar of fans after just under two hours. Since the beginning of the 2017 season, Raonic has appeared in two finals: May 2017 at the Instanbul Open and the DelRay Beach Open, where he retired, but he had yet to make an appearance in a tournament final this year. "I am so happy to have won", said Federer.
"The most important thing is going to be to focus on my game and if I can do my things well", Raonic said.
Raonic said he is not allowing any thoughts of Queen's club next week or Wimbledon enter his mind.More news: India mulls introducing retaliatory tariffs worth $241 million on United States imports soon
"I'm just concentrating on the job to hand, trying to do it well. It's nice for him, and I hope we can play another great match and I'm really excited to be in the final here".
The seventh-seeded Canadian had 19 aces and saved the only break point he faced. "There is a big difference between playing a semi and a final".
"I hope I can keep up".
The 35th-ranked Raonic, a victim of various injuries over recent seasons, was playing a final for the first time in his last 16 tournaments dating to Istanbul previous year.More news: Audi CEO Rupert Stadler arrested in diesel emission case
His last grass final came at 2016 Wimbledon in a loss to Andy Murray.
- Race 3 collection Day 3: Salman Khan film does roaring 'business'
- Saudi-Led Forces Reportedly Seize Airport of Yemen’s Hudaydah
- Meghan's diamond and pearl earrings a gift from the Queen
- Manchester United reveal asking price for Anthony Martial
- VAR Controversy: Was The Referee Right To Award France A Penalty?
- Melania Trump calls for end to migrant family separations
- Phil Mickelson Hits Moving Ball Out of Frustration at U.S. Open
- England Squad Issue Spine-Tingling 'Message To Our Supporters'
- OnePlus 6 gets another OS update, OxygenOS pushed to v5.1.7
- Genetically modified wheat found in Alberta, Japan halts shipments