Federer had a match point in the third set at 4-5, 30-40 but failed to take it, before Anderson broke in the following game to earn the opportunity to serve out the set.
Federer won the first meeting 6-4, 6-4 at the Paris Masters indoor hard-court event in 2013; he won 7-5, 6-1 at Indian Wells in 2014; 6-3, 7-5 on the clay in Rome in 2015 and 6-1, 6-1 in Cincinnati later that year.
Djokovic is a three-time victor at Wimbledon, having won the title in 2011, 2014 and 2015.
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.
The 2017 US Open finalist will meet Canada's Milos Raonic or American John Isner in his first SW19 semi-final.
Another alternative to watch Wimbledon matches featuring Roger Federer live and free is to try out the FuboTV 7-day free trial which means you can check it out without any obligation to buy.
For the first time in three years the Swiss maestro will play a match away from his beloved Centre Court lawn after organisers pencilled him in for a Court One slot.
The world number one and two-time former champion said: "Of course it's an important result for me".
"It just wasn't one of my best days", Federer, who won the first set in 26 minutes, told reporters.
"Just today, when I needed it, I couldn't get it up". It all started with Wimbledon's official Twitter handle tagging the International Cricket Council (ICC) on a post which had Federer playing what looked like a forward-defensive cricket stroke during his third-round match at the ongoing Wimbledon Championships.
It is the second time that 20-times Grand Slam champion Federer has lost at Wimbledon from two sets ahead, suffering the same fate against Jo-Wilfried Tsonga in the 2011 quarter-finals.
"It would take an unbelievable serving performance and for Roger had a bad serving day to cause an upset". This will be Djokovic's first semifinal at a major since the 2016 French Open when he completed the career Grand Slam.
"I think I had chances, I'm not sure exactly how many".
"I don't think it really mattered, to be honest".
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.
Na wins by five at Greenbrier for first victory since 2011
Knox won for the first time in two years, most recently at the Travelers Championship during his bid to make the Ryder Cup team. Kim, 24-under to start the day, fired a final-round seven-under par 65 on the par-72 Thornberry course in Oneida, Wisconsin.