Anderson serves in front of a packed Court No 1 on another sun-soaked day at Wimbledon
The eight-time champion was two sets up and had a match point in the third, but almost three hours later he trudged off on the end of a seismic 2-6 6-7 (5/7) 7-5 6-4 13-11 upset.
Federer found himself scheduled on Court One having been ousted from his usual Centre Court domain for the first time in three years.
Kevin Anderson came from two sets down to beat Roger Federer in a epic clash at Wimbledon
Federer looks dejected as he succumbs to defeat having squandered a match point in the third
Anderson and Federer shake hands at the net following the South African’s remarkable victory
Federer sits slumped in his chair following his thrilling defeat by Anderson in the quarter-finals
The setting was not the only thing alien to the defending champion.
When Anderson broke in the second set it was the first time the Swiss had dropped serve at this Wimbledon.
In their four previous meetings Anderson, 32, had not taken a set off Federer. Nor had anyone over the last 34 sets Federer had played at the All England Club, until Anderson nicked the third.
That meant Federer had equalled but not bettered his previous best set-winning streak which came between the third round in 2005 and the final in 2006. But that turned out to be the least of his worries.
There was little sign of the drama which unfolded when Federer raced through the first set in 26 minutes.
Federer plays a forehand just behind the baseline as he struggles to break Anderson down
The 36-year-old plays a backhand during his quarter-final match at Wimbledon on Wednesday
Federer stretches for the ball but fails to reach it as his Wimbledon run came to an end
Yet Anderson, the eighth seed, was meant to pose a far greater threat to Federer than his previous four opponents, and so it proved.
The first hiccup surfaced at the start of the second set with Anderson breaking the Federer serve and ending that run of holds.
Normal service was resumed for a while at least as Federer held to love before immediately breaking back and taking the ensuing tie-break.
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.
When Anderson broke again in the fourth, Federer was suddenly on the ropes.
The Swiss lost the set in a flurry of aces, with Anderson’s relentless, powerful serve sending the match into a decider.
The final set lasted 90 minutes, and it was captivating stuff. Federer eked out a break point at 4-3, Anderson quickly snuffed it out, then Anderson served to stay in the match, and did so to love.
Federer plays a backhand volley in front of a packed crowd on Court No 1 on Wednesday
The Swiss superstar squandered the chance to win the match in the third set before losing
Anderson celebrates during his remarkable comeback against the eight-time champion
On they went, both holding to love for 10-10, but at 11-11 it was Federer who blinked first, a double fault handing Anderson a rare break point which he converted.
Anderson needed four more booming serves to reach a first Wimbledon semi-final, and he found them.
Federer had been pursuing a 13th Wimbledon semi-final and a 44th appearance in the last four of a grand slam.
‘I’m not quite sure what to say, I had to try my best to keep fighting,’ Anderson told the BBC.
‘I scraped through the third and fourth sets and by the end I thought I did a great job. Beating Roger Federer will be one to remember, certainly in such a close match.
‘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. I just gave it my all and I’m ecstatic to get through that.’
Federer sweeps his hair back as he struggles to cope with Anderson’s huge serve in the match
Federer and Anderson walk off Court No 1 together after the South African’s hard-fought win