Nadal went down a set before rallying to defeat Italian qualifier Paolo Lorenzi 6-7 (5-7), 6-4, 6-0 on a hot day at Foro Italico, winning for the 38th time in 39 matches on clay surfaces.
Nadal, the two-time defending champion, is seeking his sixth Rome title and improved to 28-1 in his career at the venue. He will next face fellow Spaniard Feliciano Lopez.
Djokovic, meanwhile, ran his winning streak to start the year to 33-0 with a 6-0, 6-3 pasting of Polish qualifier Lukasz Kubot. He became the first player since Bjorn Borg in 1980 to win 33 straight to start a season.
Djokovic's next opponent will be Stanislas Wawrinka of Switzerland in the round of 16.
Federer cruised to a 6-4, 6-2 decision over Frenchman Jo-Wilfried Tsonga, setting up a meeting with Frenchman Richard Gasquet in Thursday's third round.
Wednesday's biggest upset saw Germany's Florian Mayer upend eighth-seeded Jurgen Melzer, who retired after dropping the opening set 6-4.
Rosie O'Donnell unveils nearly 50-pound weight loss
Members of Congress to keep receiving porn magazine