In the 52nd career meeting between the two players, Djokovic, the No. 12 seed, held on for a 6-4, 3-6, 7-6 (9), 3-6, 10-8 victory Saturday on Centre Court at the All England Club.
Djokovic, who has 12 Grand Slam titles, hasn't won a major in more than two years, dealing with an injured right elbow that was so painful in 2017 he quit his quarterfinal at Wimbledon and sat out the rest of the season. He had surgery in February, but results on the court since had been shaky.
The total match time was 5 hours, 15 minutes, making it the second-longest semifinal match in terms of duration in Wimbledon history.
"It really could have gone either ways," Djokovic said. "Basically until the last shot, I didn't know if I was going to win."
Said Nadal: "In my opinion, he deserved it. I deserved it too."
Djokovic will face No. 8 seed Kevin Anderson on Sunday for the title. Anderson advanced Friday with a 7-6 (6), 6-7 (5), 6-7 (9), 6-4, 26-24 victory over John Isner -- a match that took 6 hours, 36 minutes to play, a record for a Wimbledon semifinal.
Djokovic has a 5-1 edge against Anderson, including a 2-0 record against the South African at Wimbledon.
"It's been a roller-coaster ride for him the last couple rounds, but he had a day off, which means a lot," Djokovic said. "I wish I could have one."
This match was quite a contrast to Friday's battle between the hard-serving foes. Nadal and Djokovic regularly -- and spectacularly -- ran down shots to force long rallies, drawing gasps and cheers from the appreciative crowd.
Undaunted by losing his lead and being forced to an extra set, Djokovic saved break points at 4-all and 7-all in the fifth before breaking Nadal at love to end things.
"It's hard to pick the words," said Djokovic, who has won his past eight five-setters at Wimbledon. "I'm just going through things, flashbacks of the last 15 months and everything I've been through to get here."
There was hard serving as well, as Djokovic had a career-high 23 aces. That total was more than double the number he has had in any match against Nadal (11, on two occasions).
It was the first time in the Open era that both men's semifinals went past 6-all in the deciding set of a Grand Slam event. It also was just the second time in the Open era that both men's semifinals at Wimbledon went to five sets. The other instance was in 2001.
Play was halted Friday after 2 hours, 54 minutes, with Djokovic leading two sets to one. Because the match started Friday with the roof closed, it remained closed when Nadal and Djokovic took the court Saturday.
There was high-decibel, high-stakes, high-quality tennis right from the get-go Saturday, beginning with an 18-point, six-deuce game that lasted 15 minutes. It included a 23-stroke exchange and three others of at least 11.
Nadal saved two break points, and when he finally held, the owner of 17 major championships punched the air and yelled as if he had won the match.
When Nadal broke in Saturday's second game, a dismayed Djokovic grabbed a spare ball and whacked it with his racket against the wall behind the baseline.
There were other such displays of emotion from Djokovic, who is prone to yelling at himself or his coach. After rallying from a 3-0 deficit to tie the fourth set, Djokovic was broken again to trail 5-3. He reacted by raising his left shoe and violently pounded his racket against it -- one, two, three, four times.
The last men's semifinal to be finished on Saturday was in 2007, also between Nadal and Djokovic. Djokovic retired in that match because of a toe blister.
Djokovic increased his all-time lead over Nadal to 27-25 and took a 2-1 edge in five-set matches between the two. Nadal has gotten the better of Djokovic in Grand Slam matches over the years, still holding a 9-5 edge.
He also improved to third all-time with his 13th career victory against a player ranked No. 1 since the world rankings were introduced in 1973. Nadal and Boris Becker are tied for first with 19.
The Associated Press contributed to this report.