Federer broke twice to take the first set with ease, but then hit two shots long in the 10th game of the second to let the Latvian even the match.
The players traded breaks to 3-3 in the third before Federer capitalized on Gulbis' errors in the 10th game to seal the win.
The 90th-ranked Gulbis finished with 13 aces -- seven in the second set -- and did enough to impress the top-ranked player in their first meeting.
"I know that Gulbis is the player with the most potential right now," Federer said. "Unfortunately, he doesn't have the ranking he deserves. I took him very seriously. I wasn't surprised by how he played."
Nadal will face fifth-seeded Viktor Troicki, a 4-6, 6-4, 7-6 (1) winner over Lukasz Kubot.
"I am playing well," Nadal said. "There was more confirmation that I am hitting the ball well. I started well and served good. I am in the semifinals without losing a set. I am happy with that."
Nadal broke Darcis three times in the first set, and again in the second game of the final set.
"I wish him a fast recovery," Nadal said. "I hope he is fit for the Australian Open."