Defending champion Djokovic ended Federer's hopes of back- to-back claycourt titles with a gutsy 6-2 7-6 victory over the Swiss.
Five-times Rome champion Nadal wore down fellow Spaniard David Ferrer 7-6 6-0 to reach his 70th career final.
In their first meeting since last year's US Open semi- final, which Djokovic won, the Serb broke twice to win the first set.
Dominating the baseline rallies, top seed Djokovic constantly forced Federer on to the back foot and an errant forehand handed him the break for 4-3 in the second.
Suddenly Federer became more aggressive and began to vary his game and when he saved a match point at 5-4 before breaking back, he was back in the match.
But Djokovic regained his poise just in time to clinch the tiebreak 7-4 when Federer sent a backhand long.
"That was my best claycourt match of the year," Djokovic said.
"I expected him to be aggressive but I stayed close to the baseline and I felt good all the way through."
Federer said he was feeling tired having won the title in Madrid last weekend but admitted he had been outplayed.
"I thought he played very, very well," he said. "He's not the number one in the world for no reason.
"I had a couple of chances in the second set but couldn't take them.
"But I would have taken my results from these two weeks, so I am very happy going into Paris.”
In the first semi-final, Nadal made it 12 wins in a row on clay against Ferrer in a match in which a gruelling first set lasted 86 minutes.
Sixth seed Ferrer had the better of it early on and led 3-1 but Nadal fought straight back and after taking the tiebreak 8-6, he ran away with the second.
"At the start of the match, David was playing unbelievably," Nadal said. “My thought was that the best news for me would probably to be level at 3-3.
"After the first six, seven games then it was more equal because before that he was playing better than me."
Nadal said he had not played as well as he did in beating Czech Tomas Berdych in the previous round, but used his mental strength to get through.
"I was very happy with how I was mentally, because I stayed focused all the time," he said.
Nadal, who will go back above Federer to the number two spot if he wins, said he would need to be at his very best if he is to take the title.
"If I play my best clay-court tennis then hopefully I will have my chances," he said.
"It will be an important match to close the claycourt season before Roland Garros with perfect feelings."
Djokovic said playing Nadal on clay is still “the ultimate challenge" but said he believed he had the game to win again.
"Before last year, I had never won against him on clay but I won in Madrid and here, so I know I can do it."