Federer and Kyrgios produced an extraordinary range of shots in an enthralling, fiercely intense semi-final that kept a capacity crowd at Key Biscayne on the edge of their seats for the entire three hours and ten minutes of action.
When Federer won the third tie-break a furious Kyrgios hammered his racket into the ground three times as the frustration of a remarkable near-miss came flooding out.
The Australian’s big serve, touching 140 mph at times, delivered 14 aces, but Kyrgios also hit some spectacular winners and played his part in a series of stirring rallies.
But Federer was a match for most that came his way and was able to avenge his loss to Kyrgios from two years ago in Madrid also in a match which was decided by three tie-breaks.
"It felt very good. You don't very often play three breakers in a match. Winning breakers is always such a thrill," said Federer who enjoyed the battling aspect of the encounter.
Nick Kyrgios of Australia stretches for a shot against Roger Federer of Switzerland in the semi-finals at the Miami Open
"I tried to really fight for it," he said. "I can't always show my fighting skills, it is great winning this way."
While Federer now has a chance of a rare Indian Wells/Miami double, Kyrgios was left to take some compensation from his performance.
"I had some ups and up and downs, bit of a roller coaster," said the 21-year-old.
"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, though,” he added.
Kyrgios broke in the first set to go 4-3 up but Federer, with the loud crowd behind him, broke back to level at 5-5 when the Australian missed with an attempted big return.
The big-hitting Kyrgios was frequently booed by the crowd for racquet throwing and language -- and sometimes for very little -- but appeared to be enjoying the role of pantomime villain.
The first set tie-break was a gripping affair with the Australian twice having set point before it was decided when his return went wide. The boos rang out again as he hurled his racquet in frustration.
The serve dominated more in the second set and with neither player able to break another tie-break was needed. Federer had match-point at 8-7 but found the net with his return.
Kyrgios finally won the battle with an amazing cross-court return to go 10-9 up, then followed it up with a thundering ace to force a third set.
There was nothing to choose between the pair in a third set that went to yet another tie-break.
Kyrgios was furious when a fan called out during one point, and Federer enjoyed two successful challenges late on his way to a win that sent the crowd wild with delight as Kyrgios went wild with rage.
No drama for Nadal
Rafael Nadal of Spain returns a shot during his 6-1, 7-5 win over Italian Fabio Fognini at the Miami Open
There was little drama in Nadal's 6-1, 7-5 win over Italian Fabio Fognini.
The unseeded Fognini struggled to get going in the first set which was dominated by fifth-seeded Nadal and over with in 25 minutes.
The Italian, who indicated he had some trouble with his elbow, put up a better response in the second but his work was undone when he double-faulted on break point, leaving the Spaniard to serve out for the win,
Nadal will play in his fifth Miami final but will be looking for his first title in the Masters series event.
"I think I played a very good first set," Nadal said. "He had mistakes obviously. In the second, it was not about losing concentration, it's about not being lucky at the beginning of the second set.
"I had so many chances ... when you don't convert opportunities you're in trouble, and that's what happened,” he said.
Federer beat Nadal in an Australian Open final thriller in January to claim an 18th Grand Slam title and he swept past Nadal in straight sets in the fourth round at Indian Wells en route to the title there.
"If it's Roger, going to be another one for both of us, and that's it. Just another one," Nadal said of another instalment in their long-running rivalry.