The two-time champion Nadal reached the Wimbledon semi-finals for the first time since 2011 after a 7-5, 6-7 (7), 4-6, 6-4, 6-4 success.
Defending champion Federer was two sets up and had a match point in the third against Anderson, but nearly 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.
"He claims that he didn't see what Nishikori has done, but apparently he always sees what I do", Djokovic said afterward, "something that I don't think is fair".
One more straight-sets win would have Federer eclipsing his previous longest streak at the All England Club, when he won 34 sets in a row between the third round in 2005 and the 2006 final. "I felt I was playing better tennis, so that was motivating for me as well to keep at it", said Florida-based Anderson who is applying for US citizenship.
"I didn't miss much so I was very happy with the match", Federer said after booking a last-eight date with South African Kevin Anderson.
Federer suffered his earliest exit at Wimbledon since a shock second-round defeat against Sergiy Stakhovsky in 2013.
"As exciting as it is, I feel like I'm doing a good job of keeping it in perspective", he said. Today was one of those days. I feel confident in sort of baseline exchanges I'd say quite a lot with John.
He also reached last year's U.S. Open final, yet Anderson's career has been slow to come to the boil.
The 20-time Grand Slam champion appeared to be moving towards his fifth successive Wimbledon semi-final after taking the opening two sets.
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.
Federer took control of the tie-break and, despite missing a couple of opportunities before clinching the second set, it looked likely he would not only make the last four but also create a new record of winning 35 successive sets at SW19.
Only once before had Federer played more games at a Grand Slam and on that occasion, he prevailed 16-14 in the 2009 Wimbledon final against Andy Roddick.
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.
Nadal, like Federer yet to drop a set, routed world number 93 Vesely on the eve of the Czech player's 25th birthday.
Next up for Nadal is either Juan Martin del Potro, the fifth seeded Argentine, or unseeded Gilles Simon of France. Respect him - he deserved to win. "I just gave it my all and I'm ecstatic to get through that".
He's been flashing some anger this fortnight and did so again in the second set, bouncing his racket off the turf after failing to capitalize on three break points at 1-all.
Nadal is bidding to reach a sixth Wimbledon semi-final and 28th at the majors.
The 12-time major victor prevailed despite picking up two code violations and accusing umpire Carlos Ramos of "double standards".
"I think psychologically there's a huge difference for Anderson to play on Court One rather then Centre", the Swede, working as Eurosport's chief analyst, told Reuters.
"It didn't harm the grass".