Anderson has also never beaten Federer in their four prior meetings on the ATP World Tour.
When Anderson broke in the second set it was the first time the Swiss had dropped serve at this Wimbledon.
The battle between the two big-servers will start on Court 1 after the first quarter-final between Federer and Anderson.
He came into the match having won 32 consecutive sets at Wimbledon, a run he stretched to 34 before faltering.
The world number 40 was unable to mount a response this time and evidence fortune was in the Serbian's favour came on his second of two set points when a Khachanov slip enabled him to take a 2-0 lead in the match. But that turned out to be the least of his worries. "Knowing the four times they've played, Kevin hasn't got to him or seen any weaknesses from Federer, so that's a hurdle".
Ho-hum. It's another Wimbledon quarterfinal appearance for Roger Federer, who seeks a fifth straight and 13th overall trip to the semifinals at the All-England Club when he takes on No. 8 seed Kevin Anderson on Wednesday in London.
The three-time Wimbledon champion was broken in the opening game of the fourth set, but won the next four games and broke again to clinch victory.
"The fans on Court One will love seeing [Federer], maybe Centre Court ticket holders will be upset, but they have two brilliant matches to look forward to".
The final set lasted 90 minutes, and it was captivating stuff. The South African saved three break points before taking the set 7-5.
And it was Federer who blinked, double-faulting to face a break point at 11-all, then slapping a forehand into the net to cede the key break.
Kevin Anderson dethroned Roger Federer to reach his maiden Wimbledon semi-final after sealing a dramatic 13-11 deciding-set victory on Wednesday.
"I'm not quite sure what to say, I had to try my best to keep fighting", Anderson told the BBC.
"By the end I thought I did a great job not thinking about what was happening". You'll need to log-in to a cable provider to watch this way, but if you don't have that, you can still sign up for one of the above options and then use your Hulu or Sling TV credentials to sign in and watch on the ESPN digital platforms.
"It was quite a unusual feeling for me not to be able to deliver my game that I know I possess, that I know I've been delivering for so many years", Djokovic said ahead of Wednesday's quarter-finals.