In the fourth set, Federer and Anderson alternated winning the first six games until Anderson broke Federer's serve to take a 4-3 lead and then Anderson went up 5-3 thanks to strong serving before he clinched the set.
The final set lasted 90 minutes, and it was captivating stuff. Anderson held for 5-all, broke to 6-5 with a violent return victor off a 97 miles per hour second serve, then staved off three break points and closed the set with a 133 miles per hour ace. You have to have that mindset.
"Luckily for me it didn't happen", Djokovic said after he romped to a 6-4 6-2 6-2 win to reach the last eight for a 10th time. I just kept saying "today is going to be your day".
Anderson's serve is highly respected at this level, but he managed to meet the mark with an average of only 56 per cent of his first serves over the first two sets.
The decider went on serve deep into double figures, before Anderson broke in the decisive 23rd game to set up a chance to serve the match - a chance he duly took.
Djokovic copped a code violation for unsportsmanlike conduct after flinging his racquet into the grass behind the baseline in frustration early in the third set. Beating Roger Federer at Wimbledon is one I will remember. Even if Federer had managed to get past Anderson, as he nearly did, having held match point in the third set, there was no guarantee he would have gone on to win the title, especially with a rejuvenated Novak Djokovic in the other half of the draw, not to mention Rafael Nadal and Juan Martín del Potro.
It means Nadal is now in his 35th Grand Slam quarterfinal and following previous years of injuries and bad luck at SW19, the Spaniard was pleased to reach the last eight. "I think in hindsight that was a great decision", he recalled.
Roger Federer suffers shock Wimbledon quarter-final loss to Kevin Anderson
The first hiccup surfaced at the start of the second set with Anderson breaking the Federer serve and ending that run of holds. I think that's not fair. "That was very important", he added. "I'm pleased I'll be staying there right now".
The Ottawa native and partner Yifan Xu of China, the tournament's sixth seeds, defeated the unseeded pair of Bethaine Mattek-Sands of the US, and Lucie Safarova of the Czech Republic 5-7, 6-4, 6-2 in a quarter-final on Wednesday.
Nishikori, who had won only two matches in 15 meetings with the 12-time major victor, broke for 1-0 in the fourth but was broken straight back. "I really do. I think with the performances I've had, I deserve to be in the semifinals", said Djokovic, whose last major title came at the 2016 French Open.
"He claims that he didn't see what Nishikori has done, but apparently he always sees what I do".
Djokovic had been yearning for a Centre Court date, after playing as many games on Court Two as the main show court beforehand in this tournament.
"That was very important", he added.
"Rafa [Nadal] and Roger played all four matches on Centre, myself only one". "I'm pleased I'll be staying there right now".