The seven-time champion twice let a lead slip away in the fourth set Friday, then came from behind in the fifth to beat the No. 1-ranked Djokovic 6-4, 3-6, 6-1, 6-7 (3), 9-7.
Djokovic blew an easy overhead on the opening point on the final game and went on to lose serve at love, sending his final forehand long.
"I was ready for the fight," Nadal said. "I really fought a lot."
He improved to 58-1 at Roland Garros, including five wins over Djokovic. The French Open remains the only major title Djokovic has yet to win.
"It has been an unbelievable match to be part of, but all I can feel now is disappointment," Djokovic said. "I wanted this title so much."
Instead, Nadal needs one more win to become the first man to win eight titles at the same Grand Slam event. On Sunday, he'll play the winner of the semifinal between Spaniard David Ferrer and Jo-Wilfried Tsonga, who is trying to become the first Frenchman in 30 years to win the title.
In the women's final Saturday, No. 1-ranked Serena Williams seeks her first French Open title since 2002 when she faces defending champion Maria Sharapova, who is 2-13 against her nemesis.
They'll be hard-pressed to generate the sort of seesaw drama created by Nadal and Djokovic. In the fourth set Nadal twice was a break up, and twice found himself two points from victory before Djokovic summoned his best tennis of the day.
The Serb had said the French Open was his most important tournament this year, and he wanted to win it for his childhood coach, who died in Belgrade last week. On the verge of defeat, he dug in and won 10 of the final 13 points in the fourth set to even the match.
A rattled Nadal double-faulted in the first game of the final set, and Djokovic broke to take the lead. But there were more plot twists to come.
Serving at 4-3 in the fifth set, Djokovic came forward and successfully hit a smash volley, but his momentum carried him into the net and the chair umpire awarded the point to Nadal.
"I should have won that point in 99.9 per cent of cases," Djokovic said. "It was a bit unfortunate."
Three points later he drove a forehand into the net to lose the game and even the score once again.
The weather warm and sunny, Djokovic began complaining during changeovers that the clay had become too dry. He wanted the court watered, and summoned the tournament referee to argue his case, but officials declined his request.
"It got very dry and it was very slippery," Djokovic said. "I think that it's wrong what they did."
The conditions didn't hamper the quality of play. As the tension built, Nadal pulled off the shot of the day — and perhaps the tournament — in the 14th game of the set. Retreating for a lob, he flicked the ball on the run between his legs with his back to the net. That left Djokovic with an easy overhead, but he dumped it in the net, and the crowd roared at the improbable sequence.
The mistake didn't cost Djokovic, who won the game on the next point for 7-all. But the next blown overhead did, and it appeared to shake him as he lost the next three points and the match.
The last shot came 4 hours, 37 minutes after the first. A triumphant Nadal grinned, threw an uppercut and answered the fans' roar with applause for them. Then he gestured graciously toward the defeated Djokovic.
"I congratulate Novak," Nadal told the crowd. "He's a very great champion. He will win here at Roland Garros another year."
Djokovic said he'll continue to try.
"Nothing comes easy to you; you've got to earn it," he said. "Of course the feeling is not great at the moment, but I still feel I have years in front of me. So I will come back to Paris, to this Grand Slam, and I will keep on trying to win it."
Chair umpire Pascal Maria docked Nadal a point in the second set for playing too slowly, and later warned Djokovic for the same violation. But the crowd was in no rush for the excitement to end, urging on Djokovic when he fell behind and then roaring for a Nadal comeback at the end.
Along with changes in the lead, there were the sort of long, scrambling rallies that are expected when Djokovic and Nadal meet. Three strokes clipped the net on one wild exchange, which included a drop shot by each player, two lunging scoops and finally a winning volley by Djokovic, who grinned at the improbable sequence as the crowd roared.
In the end, Nadal was not to be denied on his favourite stage. His 58 victories at Roland Garros tied Roger Federer and Guillermo Vilas for the most ever.
"I congratulate him, because that's why he's a champion," Djokovic said. "That's why he's been ruling Roland Garros for many years, and for me it's another year."
Nadal won his record seventh French Open title last year, when he beat Djokovic in the final. Since returning in February from a seven-month layoff because of a left knee injury, Nadal is 42-2, winning 21 matches in a row, and on the verge of his seventh title this year.
He improved to 17-3 in Grand Slam semifinals and has won 20 of his past 21 matches against top 10 players.