Roger Federer's seemingly impossible ascent back towards the top of the men's game made further ground at the Miami Open, but his biggest test of the year looks to be around the corner.

The 35-year-old saved two match points in his quarter-final against Tomas Berdych for his 17th win of the season, which keeps him in contention for a third title of 2017 - an unthinkable set of results considering his age and six-month lay-off with a knee injury last year.

The Swiss master, winner at the Australian Open and Indian Wells, has swept aside all that has come before him so far but he next faces Nick Kyrgios in the last four in Miami. It could well be his toughest test against the mercurial Australian, who finally appears to have come of age.

Federer made it through after coming back from the brink against Berdych to win 6-2, 3-6, 7-6 (8/6), while Kyrgios won a similarly epic encounter against fellow rising star Alexander Zverev 6-4, 6-7 (11/9), 6-3.

The pair were due to meet in the quarter-finals in Indian Wells a fortnight ago but Kyrgios, who has beaten Novak Djokovic twice this year, was forced to withdraw through illness. The 21-year-old has won the only ever clash against Federer where he made it on to court in 2015.

Federer, who could potentially return to the top of the rankings later this year, admits he is lucky to be through, having been broken when he served for the match in the third set before ending up a point away from an early exit.

"I definitely got very lucky at the end, but I think I showed great heart today," Federer said on ESPN. "I fought and Tomas definitely started to step it up, but it was a great match at the end."

On his match-up with Kyrgios he added in his on-court interview: "You all should tune in if you're not in the stadium."

Kyrgios and Zverev will be doing battle at the top of the game long after Federer has called time on his career on the evidence of their quarter-final.

Nick Kyrgios defeated Alexander Zverev to set-up a semi-final clash with Federer (Getty)

The brilliant serving of Kyrgios, that was the foundation of his two wins over Djokovic, was again on display as he failed to face a break point throughout against the German.

A straight sets win looked on the cards, but Zverev raised his game and saved three match points in the second-set tiebreak, only for the Australian to bounce back strongly to take the decider.

Federer's lasting rival Rafael Nadal and unseeded Fabio Fognini do battle in the other semi-final.