The showdown between the two most successful men's tennis players in history appeared to be fizzling out before a late fightback from Nadal enabled him to avoid his heaviest-ever defeat by Djokovic.
"I'm very relieved," said Djokovic. "Everything was going my way, I was 6-1, 4-0 up but I played a sloppy service game and gave him chances."
It was 24-time Grand Slam champion Djokovic's 31st win in a rivalry that began on the same Roland Garros clay courts in 2006.
"You could feel the tension coming into the match, but also incredible hype, incredible atmosphere on the court," said Djokovic.
"I never thought back in 2006 that we'd still be playing each other almost 20 years later."
Nadal admitted Djokovic was the "clear favourite" ahead of their first clash in more than two years, with the Spaniard a shadow of the player who reigned for the best part of two decades at Roland Garros.
While 14 of Nadal's 22 Grand Slams have come in Paris, the 38-year-old has been plagued by injuries in recent years and he has slumped to 161st in the world.
His participation in the singles in Paris had been in doubt until the last minute.
Djokovic has not had a good season by his high standards but the 37-year-old Serbian rose to the occasion in his pursuit of an elusive Olympic gold.
The top seed raced into a 5-0 lead before Nadal finally got on the board but Djokovic closed out the set and surged 4-0 ahead in the second before Nadal offered some belated resistance.
Nadal clawed his way back to 4-4 only for Djokovic to break once more, this time making no mistake as he put away his old foe and perhaps brought down the curtain on one of the greatest rivalries in the history of the sport.
"When this tournament is over, I will take the necessary decisions based on my feelings and desire," Nadal said regarding his future in tennis.
Djokovic, a bronze medallist on his Olympic debut in 2008, goes on to face Dominik Koepfer of Germany for a spot in the quarter-finals.
Nadal will turn his focus to the doubles where he is in a dream-team pairing with compatriot Carlos Alcaraz.
Alcaraz, the reigning men's French Open and Wimbledon champion, saw off Dutchman Tallon Griekspoor 6-1, 7-6 (7/3) after saving a set point and receiving treatment for an apparent upper leg injury.
Roman Safiullin will be his next opponent.