The Serbian world No.2 was cruising at two sets ahead but his level dropped suddenly allowing Gulbis to make a real match of it before he managed to finish the job 6-3 6-3 3-6 6-3.
Djokovic was overpowered by Gulbis in the third set and seemed to be lacking energy in the heat but some errors by his opponent in the fourth spared him being dragged into a decider.
"Suddenly, midway through the third set (I) started to feel physically fatigued a little bit ... You could see that both me and him, we struggled on the court," Djokovic told reporters.
"I'm glad I won in four sets, because if it went to a fifth, God knows in which direction the match could go."
Djokovic will have to draw deeper on his stamina, belief and weapons on Sunday when he meets Nadal who is looking for his ninth title on the Paris clay and sent Wimbledon champion Andy Murray home for the loss of six games in their semi-final.
Nadal is trying to become the first man to win five consecutive Roland Garros singles crowns. Djokovic is looking to make his own history by becoming only the eighth man to win a career grand slam - something Nadal notched up in 2010.
"Of course pressure is there. Expectations are there. They are always present when you are playing on this level," said Djokovic, who will regain the world number one spot if he beats the Spaniard who defeated him in the French final in 2012.
"But I'm trying to channel this energy into the right direction and not get carried away too much by the stress of the occasion.
"It is the finals of a grand slam that I never won. Of course I'm going to give my best to lift the trophy in two days. I'm going to have the ultimate challenge on clay across the net, Nadal."
There were brief flashes of their best from both players on Friday, but neither man set the Philippe Chatrier crowd alight on the hottest day of the tournament at 28 degrees Celsius.
"It was not a good quality tennis at all. It was just grinding and just trying to put the ball in. Not me, not he felt the ball good," Gulbis said, in a major semi-final for the first time after 27 attempts.
Djokovic, seeded two in Paris, displayed his customary ice cool efficiency in the first two sets, more consistent from the baseline and clinical when the chances arose in the pair's first match since 2011.
But moments of casual brilliance from 18th seed Gulbis stunned Djokovic in the third which the Latvian sealed with an ace after breaking the serve of his worried-looking opponent who was having to make rapid adjustments.
"We played for over 10 days of the tournament in overcast and a little bit heavier conditions. The ball wasn't bouncing as high as it did today," Djokovic said.
"And of course it was strong sun. That also affects the fatigue of the players.
"It was a lot of exchanges we had, a lot of long rallies. But at the end of the day, in the end of the match I managed to find a necessary rhythm."
Follow the French Open on up to 7 courts LIVE on the Eurosport Player!
- Sports & Recreation