Federer, who led by two sets, held match point in the third set, only for Anderson to break his serve and launch the greatest comeback of his career.
In the 23rd game of the fifth set, Anderson finally broke Federer after the two held serve for nearly the entire set.
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.
He came into the match having won 32 consecutive sets at Wimbledon, a run he stretched to 34 before faltering.
"I just kept telling myself to keep believing, and that today it would be my day". That's the mindset you need against someone like Roger.
But, playing on Court One for the first time in three years, Federer was unusually error-prone and became visibly frustrated as eighth seed Anderson refused to surrender.
Six times Anderson was required to hold serve to stay alive and each time he was equal to the task.
"By the end I thought I did a great job not thinking about what was happening".
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. "I just gave it my all and I'm ecstatic to get through that".
After two years of physical and mental struggles, Djokovic appears fit and confident and ready to try to add to his tally of 12 grand slam titles. The tennis begins at about 2.10pm with the football kicking off at 4pm.
"I don't think it really mattered, to be honest".
After a slump following two years of nearly total domination of the men's game, Djokovic's star appears to be back on the rise and he is a clear contender to win a fourth Wimbledon title.
"He said he thinks it damaged the court". Kei did the same in the fourth set but wasn't warned.
"He claims that he didn't see what Nishikori has done, but apparently he always sees what I do".
"I am peaking at the right moment".