In a stunning turnaround in an unfamiliar setting - Court No. 1 instead of Centre Court - the No. 1-seeded Federer blew a match point and, eventually, all of a big lead in a 2-6, 6-7 (5), 7-5, 6-4, 13-11 loss to No. 8 Kevin Anderson on Wednesday.
Anderson was sticking to his guns, though, and after saving match point the eighth seed secured another break of the Federer serve and snatched a set back.
Federer, the eight-time champion, took the first two sets 6-2, 7-6 (5) on Court No. 1 to extend his streak of winning 34 straight sets at the All-England Club.
The 20-time Grand Slam victor is aiming for a 13th Wimbledon semi-final and to extend his record for the most last four appearance at the All England Club in the Open Era, having taken sole ownership of the record from American Jimmy Connors during his 2017 title run.
Anderson then held the 24th game to clinch one of tennis' most famous victories.
Federer didn't seemed bothered by being away from Centre Court when he cruised through the first set in just 26 minutes.
Already the owner of the most Wimbledon titles-eight-in history, Federer is playing like he's going to add another to his resume.
US Open finalist Anderson, who became the first South African man to reach the semi-finals at Wimbledon since Kevin Curren in 1983, said: "Down two sets to love I tried my best to keep fighting".
This quarter-final will be a different tussle altogether.
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.
Federer had been pursuing a 13th Wimbledon semi-final and a 44th appearance in the last four of a grand slam. Those are the kind of circumstances that you just have to accept.' He also revealed: 'Post-match I heard that the organisers were planning to cancel my match if Monfils and Anderson went to a fifth.
The last time he won as many consecutive sets was in 2005 and 2006 at the height of his dominance.
"I feel like a lot of aspects of my game can give him a lot of trouble", Anderson said. I think that's not fair.
Having saved Federer's only break point of a 90-minute fifth set at 3-4, Anderson took his first chance at 11-11 and then served out for victory.