British number three Bedene battled back to square the match after losing a first-set tie-break, but was edged out in the decider to lose his second-round match 7-6 (7/4) 5-7 6-4.
Bedene, up to 46 in the world rankings after his recent run to the third round at Wimbledon, had cruised through the first round in Hamburg with a 6-1 6-2 victory against Jose Hernandez-Fernandez on Wednesday.
ATP Hamburg
David Ferrer through to second round in Hamburg
26/07/2017 AT 20:46
But he found rising star Khachanov, 21, a different proposition and although he caused the world number 32 problems, he slipped to defeat in two hours and 27 minutes.
Khachanov will now play Argentina's Federico Delbonis in the quarter-finals.
ATP Hamburg
Bedene cruises into last 16 in Hamburg
26/07/2017 AT 11:33
Tennis
Verdasco handed two-month doping ban after positive test
3 HOURS AGO