The victory also came hours before Nadal's fellow Spaniard David Ferrer played the final match of his career, losing 6-4, 6-1 to Alexander Zverev in his last tournament before retirement.
Nadal has endured a turbulent few weeks after slipping to surprise defeats in both Monte Carlo and Barcelona last month before then being hit by a stomach bug on Sunday.
But there was never much sign of an upset in the Spanish capital, where the world number two opened up with a 6-3, 6-3 victory.
"Right now every victory is important for me because it gives me the option to play again the next day," Nadal said. "Two weeks ago maybe playing again was not a chance to improve because I didn't feel like that in training. Now I am feeling better in matches and I think everyone gives me the chance to get better."
Nadal has not arrived in Madrid without winning in either Monte Carlo or Barcelona since 2015 and, after also pulling out of Indian Wells due to a knee injury in March, concern was growing ahead of the French Open later this month.
The 32-year-old, who will be chasing his 18th Grand Slam title at Roland Garros, will now face another young talent in America's Frances Tiafoe, with either Stan Wawrinka or Kei Nishikori waiting in the quarter-finals.
"After Indian Wells, I had a big mental drop," Nadal said. "I had to stop for two weeks and mentally I dropped. I struggled a lot to get fit and recover that energy, which I now feel again."
Ferrer bowed out after losing to Zverev, calling time on a distinguished career that included 27 ATP titles and a highest ranking of number three in the world.
Renowned for his never-say-die attitude, the 37-year-old reached the French Open final in 2014, as well as five more Grand Slam semi-finals.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ