Federer was 4-0 against Anderson entering the day, winning every set they'd ever played against each other.
Federer's match point arrived when Anderson served at 4-5 in the third but, with the South African looming at the net, he made a hash of an attempted backhand pass.
The defending champion had not dropped a service game at this year's championships either - part of a run spanning 85 games - until Anderson broke him in the second set.
The Swiss superstar started off proceedings and held serve as did Anderson a game later. Against Anderson, though he hit 16 aces, it was down to 79 %.
The top-seeded Federer double faulted for the first time in the match when serving at 11-11, 30-30. Reaching his first grand slam final at the US Open past year, where he lost to Nadal, gave him great confidence and it was noticeable even early on that he was able to push Federer back, a rare sight, especially on grass.
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. Now I feel horribly worn out and just terrible. Djokovic grunted and groaned, he took on chair umpire Portugal's Carlos Ramos, who he accused "of double standards", and was handed two code violations, in the second and fourth sets, for racket abuse and time violations, but he also produced razor-sharp tennis. "I kept saying that today was going to be my day, because you really need that mindset taking the court against somebody like Roger", Anderson said.
It was the biggest shock in a tournament already brimming with surprises, especially as Joahannesburg-born Anderson had not even won a set in their four previous meetings.
The 32-year-old is playing in the last eight at the All England Club for the first time since finishing runner-up to Djokovic in 2011.
England knocked out after semi-final loss to Croatia
Speaking to the presenter Marc Pougatch, Keane says: "Before the game, we were talking about England and the final , France ". The goal was followed by a series of chances for England as Croatia struggled with the pace of the Three Lions' attack.
Now the 32-year-old South African moves on to face number nine John Isner of the USA on Friday.
Next up for Anderson is a semi-final on Friday against either John Isner, the ninth seeded American.
But, playing on Court One for the first time in three years, Federer was unusually error-prone.
Djokovic defeated 24 seed Kei Nishikori in four sets on Wednesday at Wimbledon, 6-3, 3-6, 6-2, 6-2, to advance. After making it to the fourth round of the Australian Open, an event where he's dominated historically, Djokovic lost in the first round of several masters events, including the Indian Wells Masters and the Miami Open. I'm going to play semifinals back there again.
Soon enough, Djokovic was on his way to the semi-finals, where he will meet Rafael Nadal.
" I think I had chances, I'm not sure exactly how many".
Two-time Wimbledon champion Nadal, who is chasing an 18th Grand Slam title, won the pair's most recent clash in the semi-finals of the French Open last month.
"I felt good actually".
"That was something I learned from 2016 where I constantly tried to get back into competition too quickly".