The world No. 1 battled back from two sets to one down against giant Argentine Juan Martin del Potro to win 7-5 6-7 4-6 6-4 6-4.
It was the pairs third meeting in the past four Grand Slams, with Nadal coming out in both the previous encounters – and it followed suit after a dramatic five-setter.
The final near-five-hour match on Centre Court brought about the end of a fabulous day of tennis action.
Djokovic had earlier downed Kei Nishikori to return to the semi-finals at the All England Club for the first time since 2015, before Federer suffered a stunning exit at the hands of big-serving South African Kevin Anderson, who will face John Isner after his victory over Milos Raonic.
The timing of this one – a match thats decider was described by Andy Murray in the BBC commentary box as one of the best sets of tennis I have ever seen live – was somewhat unfortunate as it clashed with Englands World Cup semi-final. Despite starting some three hours before kick off, it lasted the full 90 minutes.
After the match, the second seed told the BBC: It was a very emotional match – great qualify of tennis.
I feel sorry for Juan Martin. Hes an amazing opponent, an amazing player, in some ways he deserves the victory too.
A good start to the match felt key for Del Potro, who was forced to play on both Monday and Tuesday against Gilles Simon in a four-and-a-half-hour last-16 tie.
He survived his first real test at 3-4, negotiating a lengthy rally at 15-40 before sending down a booming serve to hold.
However, the Argentine crumbled at 5-6, handing the Spaniard a one-set lead.
Del Potro responded well and served for the set at 5-4, but the world No. 1 pegged him back again.
Closing in on a two-love lead, Nadal double faulted on set point and Del Potro reacted quickly to level the tie.
Fully fired up, the Argentine held his serve with ease throughout to third before firing a huge forehand winner to break and take the set to love.
A couple of slips from the fifth seed gave Nadal a sniff and after the Spaniard broke for a 3-2 lead in the fourth, Del Potro thumped a ball at full pelt into the turf in frustration.
Though Del Potro held off a few more break points, he had no chances to get back on level terms and Nadal took the match into a fifth.
In the decider, the pair played the point of the tournament. A stunning 24-shot rally ended with Del Potro pulling off the most sublime diving volley and avoiding facing a break point.
On Del Potros next service game, Nadal ended up in the crowd after chasing down an angled shot from his opponent. Fortunately he negotiated his landing well after leaping over the barrier between the supporters and the court.
The action continued to roll in on the Del Potro serve and it was Nadals turn to slip flat onto his back but he picked himself up and rasped a backhand winner to snatch the crucial break.
Del Potro should have levelled moments later. After sending Nadal wide with a thumping forehand, he had the court gaping and at his mercy but a horrible shank let the Spaniard off the hook.
The 2009 US Open champions spirit never died and he set up another three break points but Nadal relentlessly moved just one game away from the semi-finals after a 13-minute game.
And he served it out to book a tie with three-time champion Djokovic.