The 35-year-old's victory sets up a re-match of January's Melbourne Park title-decider against Spaniard Nadal, who earlier rolled over unseeded Italian Fabio Fognini 6-1 7-5.
Kyrgios, who has twice beaten Novak Djokovic over the last month, left his racket a twisted heap on the court after coming up short in a battle against the former world number one and a partisan crowd.
In their only previous match in Madrid in 2015, the Australian came out on top in a similar three-set thriller that went to three tiebreaks with the last decided 14-12.
"It's great winning this way, especially of course I remember the loss against him few years ago," Federer told reporters.
"I know I can't always show my fighting skills because everything else sort of takes over."
The temperamental Kyrgios came apart in the late stages of the last tiebreak after a fan yelled out when he was leading 5-4 and he miscued a forehand.
The 21-year-old turned to the fan and unleashed a volley of obscenities before serving up a double fault that gave Federer the window he needed to clinch the battle. "Obviously, I'm an emotional guy. I had some ups and up and downs, bit of a roller coaster," Kyrgios said.
"Ultimately, I think I put in a good performance. I thought the crowd would've enjoyed watching it, people at home would've enjoyed watching it. But, I wouldn't be surprised if they found something bad to say about me."
Nadal, who lost all four of his previous Miami Open finals, will be out to snap a run of three straight defeats against Federer, including in the Melbourne final and at Indian Wells.
"Winning here would be something great, and an important title I haven't won," Nadal told reporters. "I served well (today). That gives you calm when you have opportunities on the return."
The fifth-seeded Spaniard did not face a break point against Fognini and put his opponent's serve under pressure throughout the 90-minute match.
The 30-year-old raced through the first set in 26 minutes, losing only four points on serve while Fognini made 14 unforced errors.
"I was missing a lot of balls," Fognini said. "I give him a present of the first set. I was playing really bad."
The Italian came to life in the second set, especially in a stretch where he fended off five break points during his first two service games.
At 5-5, however, just when it looked as if Fognini might force a decisive third set, he double faulted and Nadal grabbed the break before sealing the match four points later.
(Reporting by Frank Pingue and Jahmal Corner; Editing by Ken Ferris/Nick Mulvenney)
Share
