Federer won the Australian Open in January - his first Grand Slam success in five years - despite not playing in the previous six months, claimed the BNP Paribas Open at Indian Wells in March and won the Miami Open two weeks later.
Khachanov was leading 3-2 when Nishikori called it a day and will take on fellow young Russian Andrey Rublev in the quarter-finals.
Federer gained the advantage over Zverev in the tiebreak with a pair of backhand passing shots, ultimately leading him to a first-set victory.
France's Richard Gasquet is also through after a 6-1 3-6 6-1 victory over Robin Haase. The Swiss maestro spoke about Andy Murray, Novak Djokovic, and Rafael Nadal. "I think what Nadal did at the French Open stands out".
Federer triumphed in their first meeting on clay in the 2016 Italian Open with a straight set win in the round of 32 while Zverev got a win in the 2016 Halle Open semi-final.
Gasquet will play his first Halle semi-final since 2013 against either German fourth seed Alexander Zverev or Spain's Roberto Bautista Agut. Roger raced to a 4-0 lead, breaking Sascha in games 1 and 3 to gain the authority in the first set, and he sealed it with the third break in the game 7.
China talks focusing on North Korean threat
China's top diplomat Yang Jiechi and General Fang Fenghui met Tillerson and Defense Secretary Jim Mattis during the talks. USA and Chinese diplomats and defense chiefs are meeting later Wednesday in Washington for security talks.
Federer, who is bidding for his 16th grass-court title, owns a 56-6 career mark with eight championships in Halle.
Mayer and Zverev may have the backing of the German fans in Halle, but Federer can never be counted out. "He uses slice, he comes in, he chips and charges, he loops the ball and serves/volleys a little bit, so he's really going to throw everything at me", said the Swiss great.
His huge serve was on full display when he won the 's-Hertogenbosch title on grass last week and once again he used it to devastating effect against Querrey.
Speaking at the post-match presentation, Federer said: "It's been a hard year - we had a lot of practice, a lot of training, a lot of rehab to do, so it's nice to be back on the match courts and it feels great". "I'm still just very happy how I was able to close it out in the breaker".
"I would say that's the best performance I've seen from Federer this season", said Cowan.