Nadal's performance, and sometimes sluggish movement on the court, raised questions about whether he will be able to successfully defend his title at the French Open. The year's second Grand Slam starts in 10 days.
Nadal will next face fourth-seeded David Ferrer, who advanced when Philipp Kohlschreiber of Germany withdrew because of dizziness.
Top-ranked Novak Djokovic had a far easier time than Nadal, beating Alexandr Dolgopolov 6-1, 6-4 to improve his clay-court record this season to 8-1. Also, second-seeded Roger Federer breezed by Gilles Simon of France 6-1, 6-2.
In women's action, Serena Williams routed 14th-seeded Dominika Cibulkova 6-0, 6-1 for her 21st consecutive win, matching the best streak of her career. In the other half of the draw, second-seeded Maria Sharapova swept aside No. 16 Sloane Stephens — the American who reached the Australian Open semifinals — 6-2, 6-1.
Nadal, however, was far from his best, especially in the first set, in which Gulbis took a 5-0 lead and even had a point to close out the set at love.
But Nadal, who has reached the final in all seven tournaments he has played since returning to the circuit in February from a seven-month break because of a left knee injury, eventually began to win the longer points while the carefree Gulbis started to commit more errors.
Nadal won last week's Madrid Open but his run of eight consecutive titles in the Monte Carlo Masters ended last month with a straight-set loss to Djokovic in the final. Nadal said this week he now trains for about 50 minutes a day compared with two hours a year ago.
"I really don't want to talk about my knee. I'm fine. I (fought) a lot to be where I am today," Nadal said. "These matches like today where you're in trouble all the time but you keep fighting for every ball, this victory means a lot. To have another one like this is very special."
Gulbis had given Nadal trouble before, also taking a set off the Spaniard in four of their previous five meetings, all of which Nadal won.
For the first half of this match, Gulbis dominated with his big serve and forehand while Nadal made a series of forehand errors. At one point late in the first set, Nadal didn't even move when Gulbis returned his serve within reach.
Gulbis held serve in all 17 games of his first two main-draw matches and Nadal didn't break him until he took a 5-3 lead in the second set. At times, Nadal was returning so far behind the baseline that Gulbis was able to step into the court and push Nadal to the corners.
"I thought I was the better player in the match," Gulbis said. "But he is the champion and, well, I lost against him in Indian Wells when I also thought I played better than him. He is solid and he didn't do anything special and I made mistakes and so he won."
Nadal didn't agree with Gulbis' assessment.
"Normally — I don't say always, but normally — the best player wins," Nadal said. "If the best player was the one who tried to find solutions against a player that tried to hit every ball very hard. ... I (kept) fighting and concentrating every moment. ... If that's something then probably the best player won."
Gulbis has had success in Rome before, upsetting Roger Federer in the second round in 2010 and reaching the semifinals, where he lost a close three-set match to Nadal.
Gulbis won his third career title in Delray Beach, Florida, in March as a qualifier and his ranking is up to No. 46 this week after finishing last year at No. 135.
"Gulbis is a fantastic player. He sometimes needs to pace himself," Nadal said, criticizing Gulbis for asking the chair umpire to come down and check several ball marks. "He needs to be a little bit more calm. And if he is, he has a great chance to be in the top positions because his game is great."
It was the third time in 303 clay matches that Nadal lost the opening set 6-1, according to the ATP. The others he also came back to win — in the 2011 Davis Cup against Juan Martin del Potro and in the 2006 French Open against Roger Federer.
Earlier, Djokovic again showed no signs of the right ankle injury that slowed him during last week's Madrid Open, when the Serb lost in the second round to Grigor Dimitrov.
"I haven't felt any pain or discomfort on court for a week already so that's great news," Djokovic said.
Djokovic has reached the Rome final four of the five past years, winning the title in 2008 and '11. He'll next face sixth-seeded Tomas Berdych, who defeated Kevin Anderson of South Africa 7-5, 6-2.
Two men's seeds lost, as No. 7 Juan Martin del Potro was beaten by 36th-ranked Benoit Paire of France 6-4, 7-6 (3); and No. 9 Richard Gasquet fell to rising Polish player Jerzy Janowicz 3-6, 7-6 (2), 6-4.
With local hope Sara Errani of Italy playing in the main stadium, Williams was forced to play on an outer court. She didn't make the appearance last too long, winning in 61 minutes.
Williams has twice before won 21 consecutive matches, although both of those streaks came more than a decade ago, in 2002 and 2003. The 15-time Grand Slam singles winner has won her previous three tournaments.
Elsewhere at the Foro Italico, two-time champion Jelena Jankovic edged fifth-seeded Li Na of China, 7-6 (2), 7-5 and will next face Romanian qualifier Simona Halep, who beat 13th-seeded Roberta Vinci of Italy 6-4, 6-2.
The last remaining Italian in the tournament is Errani, who advanced when 12th-seeded Maria Kirilenko of Russia retired while trailing 6-3, 2-0 with a left knee injury. Errani will next face Sharapova.Suggest a correction