He and Shapovalov exchanged service games in the opening set until the seventh game when Nadal found the break. Nadal had the advantage point four times while Shapovalov had one before taking the game on his second opportunity, to win and take a 2-1 lead; his only time in the match.
"We're finally connecting and I think that's the most handsome thing", Fognini said of the crowd, which whistled him off the court following an erratic performance a few years ago. The seven-time champion opened his campaign with a commanding 6-1, 6-0 win over the 31st ranked Damir Dzumhur to reach the third round.
Nadal is also attempting to win the top spot back this week.
The 24-year-old destroyed his racket in fury as he suffered his first loss to Fognini in three meetings, sinking 6-4 1-6 6-3.
Shapovalov, 19, stunned Nadal in the third round in Montreal past year to deny the Spaniard a chance to regain the No 1 spot. "So, I think it's a good thing that I played here".
And while Nadal would eventually break at 3-3 and take the first set 6-4 in 50 minutes, he admitted afterwards that he had been worked hard for his quarter-final place.
Germany's Alexander Zverev, who beat Djokovic in last year's final, kept his title defence on track but needed eight match points to see off Briton Kyle Edmund 7-5, 7-6 (13/11).
Cilic will play 10th-seeded Pablo Carreno Busta, who beat Aljaz Bedene 6-4, 6-7, 6-2.
Djokovic, back after a troublesome elbow injury, showed flashes of his formidable best as he beat Spain's Albert Ramos-Vinolas 6-1 7-5 and will meet Japan's Kei Nishikori in the next round.
To stay in top spot, Halep needs to progress further than No 2 Caroline Wozniacki, who was facing 15th-seeded Anastasija Sevastova in a late match.
The Romanian, a finalist in Rome a year ago, is on her way to holding on to top spot as she next plays France's Caroline Garcia who dumped out US Open champion Sloane Stephens 6-1, 7-6 (9/7).
Fourth seed Marin Cilic displayed plenty of patience during his 6-3 6-4 win over Frenchman Benoit Paire.
Meanwhile, former world number one Karolina Pliskova smashed the umpire's chair in frustration after she lost to Greece's Maria Sakkari in the second round.
The victor will play Anett Kontaveit, who ousted 1999 victor Venus Williams 6-2, 7-6.
This is the last major warmup for the French Open, which starts in 10 days.
Three-time victor Maria Sharapova ousted Daria Gavrilova 6-3, 6-4 and will play fifth seed and French Open champion Jelena Ostapenko who saw off Britain's Johanna Konta 2-6, 6-3, 6-4.