The 35-year-old, who is bidding for a record eighth title at Wimbledon next month, won 6-4 7-6 (7-5) in Halle.
Khachanov missed two set points to take the match into a decider, with Federer hanging on before taking the tie-break.
The Swiss top seed will play 20-year-old German Alexander Zverev, who beat Richard Gasquet, in Sunday's final.
Fourth seed Zverev, who beat Federer in the semi-finals last year before losing to Florian Mayer in the final, won 4-6 6-4 6-3 against France's Gasquet.
Eighteen-time Grand Slam winner Federer lost to 39-year-old Tommy Haas at the Stuttgart Open last week, his first match in two months, but is yet to drop a set as he bids for a ninth title at Halle.
However, he was given a stern test by 21-year-old Khachanov in their first meeting.
While Federer is considered one of the greatest grass-court players of all time, 38th-ranked Khachanov was playing in his first tournament on the surface.
Find out how to get into tennis in our special guide.
Federer took an early advantage after the opening three games all produced breaks of serve, going on to seal the first set at the second attempt before Khachanov pushed him in another tight set.
Federer took his opponent's serve for 5-4, leaving the world number five serving for the match, only for Khachanov to break back and level.
After missing his chances to win the set at 6-5, Khachanov fought back from two mini-breaks in the tie-break, but fired long after his own serve on match point.
Federer has already won three titles this season, including the Australian Open - his first Grand Slam success in five years.
Federer also won the BNP Paribas Open at Indian Wells in March and, two weeks later, the Miami Open.
In May, he announced he would be missing the French Open and the rest of the clay-court season to concentrate on the grass and hard-court seasons.
Another success at Wimbledon will put Federer clear of Pete Sampras' joint-record seven men's singles victories in SW19.
Roger Federer continued his Wimbledon preparations by reaching the Gerry Weber Open final with a hard-fought win over young Russian Karen Khachanov.