The third seed needed to take a medical time-out to treat a back injury before playing on for a few points and retiring with the score at 3-2 in the first set for the Russian.
Wimbledon, the only grand slam to be played on grass, starts on July 3.
Khachanov will now play the winner of the match between fellow Russians Mikhail Youzhny and Andrey Rublev.
ATP Halle
Federer thrashes Zverev to claim ninth title at Halle in style
25/06/2017 AT 12:12

Results from Round 2 of the Halle Open Men's Singles

Andrey Rublev (Russia) beat Mikhail Youzhny (Russia) 6-0 3-6 6-3
Karen Khachanov (Russia) beat 3-Kei Nishikori (Japan) 3-2 (Nishikori retired)
ATP Halle
Federer moves into 140th career final at Halle
24/06/2017 AT 13:06
ATP Halle
Federer eases past Mayer to reach Halle semi-finals
23/06/2017 AT 16:17