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: How you can buy Meghan Markle’s Stella McCartney wedding dress
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: Reporter, Sanders spar over plight of immigrant children separated from parents
"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: Melania Trump calls for end to migrant family separations
His last grass final came at 2016 Wimbledon in a loss to Andy Murray.
- The Queen and Meghan Markle share their first royal visit together
- The iPhone 3GS is going on sale, and no, it isn't 2009
- Meghan's diamond and pearl earrings a gift from the Queen
- England Squad Issue Spine-Tingling 'Message To Our Supporters'
- OnePlus 6 gets another OS update, OxygenOS pushed to v5.1.7
- Walmart shooting: Gunman killed by armed civilian in Washington store parking lot
- 3 confirmed dead in Japan earthquake, dozens injured
- VAR controversy, Argentina held by Iceland and more
- VAR Controversy: Was The Referee Right To Award France A Penalty?
- Conway says 'nobody likes' family separation policy