But after squandering a match point in the 10th game of the third set Federer's game frayed at the edges and an inspired Anderson powered back to claim victory in four hours 14 minutes.
Two-time champion Nadal is through to the last eight at Wimbledon for the first time since 2011.
During his Wimbledon fourth-round victory over Adrian Mannarino on Monday, with the ball having already been called out, Federer played a stroke that was more akin to cricket than tennis.More news: Rafa Benitez gives his verdict on England's World Cup hopes
Federer, who won the match against the Frenchman in straight sets, was afforded high praise for the shot too.
Not since Wayne Ferreira in 1994 had a South African man made the Wimbledon quarter-finals, but Anderson wasn't overawed by the occasion.
After a marathon final set, a double fault on Federer in the 23rd game was ultimately what did in the No. 1 player. South Africa's Kevin Anderson celebrates after winning his quarter final match against Switzerland's Roger Federer. His last semifinal appearance at a Grand Slam was at the US Open in 2016, where he lost in the final to Stan Wawrinka. It's one of those average days you have to try to win the match, and I just couldn't get it done today.More news: Pakistani authorities arrest ousted premier Nawaz Sharif's son-in-law
Federer, playing in the unfamiliar surroundings of Court One for the first time in three years, oozed confidence as early as the opening game when he broke Anderson's huge serve easily and then again in the ninth game before serving out the set in 26 minutes.
"I think I had chances, I'm not sure exactly how many". Watch Roger Referer vs Kevin Anderson live streaming online on ESPN TV this morning at 8 am EST / 5 am PST with a spot in the semifinals at stake. He ended the match with a serve down the middle that. He even asked Federer if they could exchange notes on cricket and tennis after the latter won his ninth Wimbledon title.
Fans of Switzerland's Roger Federer cheer during the fifth set of his men's quarterfinals match against Kevin Anderson of South Africa at the Wimbledon Tennis Championships, in London, Wednesday July 11, 2018.
Of the five points he lost in the 16-minute opener three were in the final game when he faced his first break point of the tournament - and answered it with an ace.More news: Turkey's Erdogan sworn in with new powers, names son-in-law finance minister