Four-time Rome winner Novak Djokovic reached his first quarterfinal of the year with a 6-1, 7-5 victory over Alberto Ramos-Vinolas.
Djokovic next faces Kei Nishikori, who rolled past Philipp Kohlschreiber 6-1, 6-2.
The 19-year-old Shapovalov stunned Nadal in the third round in Montreal last year to deny the Spanish player a chance to regain the No. 1 spot.
Nadal is also attempting to win the top spot back this week. He'll replace Roger Federer if he wins an eighth Rome title.
In a match between two left-handers, Shapovalov saved eight break points in his opening two service games before finally dropping his serve midway through the first set.
"He was really serving big and I had some mistakes with the return," Nadal said. "It was not a comfortable match against a lefty who serves big and goes for his shots.
"He's good in all aspects. The only thing he needs is a little bit more time."
Shapovalov was stretched to three sets in his opening two matches, against 15th-seeded Tomas Berdych and Robin Haase, and reached the semifinals of last week's Madrid Open.
"I didn't feel completely dead out there but I felt like I could've been fresher," Shapovalov said.
Nadal, who hasn't won the Italian Open since 2013, next faces Fabio Fognini, who beat Peter Gojowczyk 6-4, 6-4.
Fognini slammed his racket midway through the second set and received a warning from the umpire but otherwise held his composure to follow up an impressive win over Dominic Thiem.
Defending champion Alexander Zverev needed eight match points before completing a 7-5, 7-6 (11) win over Kyle Edmund.
His next opponent will be ninth-seeded David Goffin, who was leading 6-2, 4-5 when Juan Martin del Potro retired because of a groin injury.
Fourth-seeded Marin Cilic defeated Benoit Paire 6-3, 6-4 and will meet Pablo Carreno Busta, who beat Aljaz Bedene 6-4, 6-7 (3), 6-2.
In the women's tournament, Simona Halep's hold on the No. 1 ranking received a boost when American Madison Keys withdrew from their last-16 match due to a rib injury.
Halep now needs to progress further than No. 2 Caroline Wozniacki to stay in top spot.
Wozniacki beat 15th-seeded Anastasija Sevastova 6-2, 5-7, 6-3 and next faces Anett Kontaveit, who ousted 1999 champion Venus Williams 6-2, 7-6 (3) for her second win over the American in two weeks.
Last year, Halep rolled her ankle in the final and lost a lead and the championship to Elina Svitolina.
Halep next plays seventh-seeded Caroline Garcia.
Svitolina overcame a poor start to beat 14th-seeded Daria Kasatkina 0-6, 6-3, 6-2. She'll now face former No. 1 Angelique Kerber, who routed Maria Sakkari of Greece 6-1, 6-1.
This is the last major warmup for the French Open, which starts in 10 days.
Jelena Ostapenko, preparing to defend her title at Roland Garros, rallied past Johanna Konta 2-6, 6-3, 6-4 and will meet three-time Rome champion Maria Sharapova, who eliminated Daria Gavrilova 6-3, 6-4.
More AP tennis coverage: https://apnews.com/tag/apf-Tennis
Andrew Dampf on Twitter: www.twitter.com/asdampf
Copyright 2018 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.