Nadal's win on clay court at the Internazionali BNL d'Italia in Rome extended his winning streak to 16 matches.
The fourth-seeded and No. 4-ranked Spaniard was leading 3-0, 15-30 against his fellow countryman when Almagro grabbed his left knee and was unable to continue after 24 minutes.
Almagro, ranked No. 73 and coming through qualifying, got some medical attention at his chair but quickly retired from the second-round match.
"It's difficult to see what's going on now just after what happened," Nadal said afterward. "He felt something on the knee."
Nadal won consecutive clay-court tournaments in Monte Carlo, Barcelona and Madrid, and is going for an eighth title at the Foro Italico in his preparation for the French Open, which starts in Paris on May 28.
Nadal will next face 13th-seeded American Jack Sock, who outlasted Jiri Vesely of the Czech Republic 6-4, 3-6, 7-6 (1) after more than 2 1/2 hours.
Third-seeded Stan Wawrinka of Switzerland defeated Benoit Paire of France 6-3, 1-6, 6-3, No. 5 seed Milos Raonic of Canada beat Germany's Tommy Haas 6-4, 6-3 and seventh-seeded Kei Nishikori of Japan stopped Spain's David Ferrer 7-5, 6-2.
In the other men's matches, former world No. 4 Juan Martin del Potro of Argentina defeated Kyle Edmund of Great Britain 7-5, 6-4, 16th-seeded Alexander Zverev of Germany beat Viktor Troicki of Serbia 6-3, 6-4 and American Sam Querrey posted a 6-4, 6-3 win over German Jan-Lennard Struff.