Earlier, Federer beat fellow Swiss Marco Chiudinelli 7-6 (5), 7-5.
Nadal, who also is playing doubles with Marc Lopez, had a fever earlier this week and looked uncharacteristically slow and sluggish. In the second set, he won just five of 18 points on his serve -- and 11 of 37 overall.
"It was a very difficult match," Nadal said. "I wasn't 100 percent yesterday and it was the same today. I said that during the press conference yesterday. I was more tired after I played the doubles matches here. But I will not stop. I will play doubles."
It was only the 10th time in 575 career matches that Nadal lost a set 6-0, and the first since the decisive set of a final against Andy Murray at Rotterdam, Netherlands, in February 2009, when the Spaniard was bothered by a knee injury.
Nadal picked up his game in the decisive set, breaking twice for a 3-0 lead after several unforced errors by Lacko. After dropping his serve once, Nadal broke again to clinch the match.
Federer needed a strong baseline game to overcome Chiudinelli and stay in the hunt for a third tournament title in Doha.
"It was an up and down match. I was a bit confused and lost focus [at the end of the first set], but I did well to concentrate better as the game went on," Federer said. "It's not easy to play [Chiudinelli] because we know each other's game quite well. But I am happy to advance here."
On Thursday, Federer will play Viktor Troicki of Serbia in the quarterfinals of the season-opening tournament.
Chiudinelli, who twice asked for help for a stiff back during the match, saved a set point in the 12th game to force the opening tiebreaker. In the second set, Chiudinelli broke Federer in the fourth game but Federer rebounded and broke his countryman twice to earn the win.