The 12-time Grand Slam champion then raised his level in the fourth set and finished with a victor into the corner to book his place in Friday's semi-finals where he was joined by a familiar foe as Nadal won through late in the day.
Defending champion Federer lost a Court One thriller, 2-6, 6-7 (5-7), 7-5, 6-4, 13-11 as 32-year-old Anderson became the first South African in the Wimbledon semifinals since Kevin Curren in 1983.
When the Croatians faced off against hosts Russia in their quarter-final many Serbs who gathered to watch in cafes in central Belgrade were backing the Russians rather than their neighbours from the former Yugoslavia.
"It was just one of those days where you hope to get by somehow", said Federer, who last played at No. 1 Court in 2015.
Anderson was the runner-up to Nadal at last year's U.S. Open, but he never made it beyond the fourth round at Wimbledon until this week.
Seeded 12, Wednesday will Djokovic's 41st appearance in a Grand Slam quarter-final. I am very grateful to play on the court I love and to be competing at a high level. He was within touching distance as he held to 30 for a 5-2 buffer and, much like the preceding set, he rammed home his superiority to seal the set - and the match - with a double break. "I knew how I threw the racquet", Djokovic later explained.
The Serbian, Djokovic, maintained the dominance he has shown throughout the tournament on his first serve.
Eight-time champion Federer has already won more Wimbledon singles titles than any other man, but was aiming to equal Martina Navratilova's all-time record.
This time it was the Serb who saved three break points before he let out a huge roar when, with momentum on his side, he broke Nishikori in the next game. "I think confidence is back for him". "Djokovic is a national hero and I thank him - but support Croatia, how can he not be ashamed?"
Scheduled last on No. 1 Court, Djokovic and Khachanov did not get underway until after 19:00 local time at the All England Club on Monday.
Nishikori still would not fade and he forced Djokovic to go long for an early break in the fourth, but that advantage was swiftly canceled out following another fine rally.
"I think it's not fair, but it is the way it is in the midst of the emotions of a match".
"I want to use today's result as a spring from which to aim for a final place".