Federer suffered his earliest exit at Wimbledon since a shock second-round defeat against Sergiy Stakhovsky in 2013.
"I had my chances", Federer said, "so it's disappointing."
Boris Becker said Anderson had played the "game of his life" and, to many, will be known as the man who ended Federer's run.
"Down match-point, and two sets to love, I just tried my best".
And he did not disappoint with a battling performance reminiscent of days gone by, even if he did fall out with umpire Carlos Ramos. That's the mindset you need against someone like Roger. Now I feel horribly tired and just terrible.
For the only the second time at Wimbledon, Federer was beaten after holding a two-set lead, with his previous loss from that position coming against Jo-Wilfried Tsonga in the 2011 quarter-finals. If it gnawed at him, there was no evidence as the match surpassed the four-hour mark.
That initial burst gave Federer 34 successive sets won at Wimbledon, equalling his own record set between 2005 and 2006.
Anderson's attempt to serve out the set was not without drama but, though Federer brought up a break-back point, a searing cross-court backhand saved it and a forehand into the left corner secured a decider. The Swiss lost his serve, putting the match in Anderson's big-serving hands.
It was his first win against Federer at the fifth attempt and means he is the first player representing South Africa to reach the semi-final here since Kevin Curren in 1983.
Federer had been pursuing a 13th Wimbledon semi-final and a 44th appearance in the last four of a grand slam.
Novak Djokovic, Nadal's one-time archrival, has had a lot of ups and downs over the past few years, but he's back in the semifinal to face off against Nadal.
Federer had breezed into the quarter-finals without dropping a set for the eighth time and was imperious in the opening set in which he hit 10 winners and only three unforced errors.
The World Cup showpiece will take place on Sunday at 18:00 (local time), which is 16:00 BST, meaning it is likely to kick off during the men's grass-court final, which eight-time champion Federer is a heavy favourite to be a part of.
Anderson is getting used to breaking barriers. I scraped through the third and fourth sets. Not only has he yet to drop a set through four matches at the All-England Club this year, but he hasn't had his serve broken, and it wasn't until his last match against Adrian Mannarino that he faced his first break point.
It was a match Federer could, probably should, have won and yet he will now leave here wondering - probably like everyone else - how many more chances he will get to add to his eight Wimbledon titles.
Croatia v England: Why Wednesday must be Harry Kane's day
England has gone with a 3-5-2, and the only change was to start Ruben Loftus-Cheek in midfield after Dele Alli injured a thigh. Now, this is a massive day for the English team, it's their first World Cup semi-final in 28 years.
Belgium is the most exhaustive team in all aspects: Lloris
Let us know your thoughts - and if you threw the remote at the TV during Alli's celebrations - by posting a comment below. When I played against him (in the Champions League in February 2017) he had played only 10 matches and I didn't know him.
The Galaxy Note 9 is set to be another disappointment
The first official Galaxy Tab S4 press render has been leaked online and it reiterates what we know about the tablet so far . South Korean tech giant Samsung is now working on its 10th generation Galaxy S smartphones - S10 and S10 Plus.
Jose Mourinho praises 'mature' Paul Pogba after France win
The experienced Croatian team is led by arguably the player of the tournament so far, Luka Modric. "We don't want to stop". One thing to keep an eye on in this match is the legs and how exhausted the players will be, especially with Croatia.