With Canadian icon Wayne Gretzky watching in the stands, Shapovalov rallied to stun Nadal 3-6 6-4 7-6 (7-4).
In the quarterfinals, Shapovalov will take on Adrian Mannarino.
Ferrer has now lost all of his 17 contests against Federer, who is vying to take the world number one spot from injured Briton Andy Murray.
Wimbledon and Australian Open victor Roger Federer, who has won seven Cincinnati titles including crowns in 2014 and 2015, will be the second seed - marking the first year since 2009 that Nadal and Federer are the two top seeds in Cincinnati.
Federer will next face the victor of a match between American Jack Sock and Spain's David Ferrer. I think I started playing so well in the first set and in general, I played a great match.
Federer, 36, has never lost in 16 previous meetings with the 35-year-old Ferrer, whom he first defeated 14 years ago at the Vienna Indoor tournament. But Shapovalov still did tremendously well to overcome the nerves he was likely feeling, and put in another great performance against a top player. He saved the one break point he faced during the match, and dropped just six points on his first serve and seven on his second.
"He's the best players I've ever played in my life".
The Wimbledon champion came from behind to beat David Ferrer in Montreal
Federer was soon in control in the second set, scoring an early break and holding twice to move 3-0 up before a further break made it 4-0. The two left-handers battled for two hours and 46 minutes.
Federer also progressed to the last eight, with victory over David Ferrer.
Ousting lower seeds were South African Kevin Anderson beating No. 11 Pablo Carreno 6-3, 7-6 (6), and former Top 10er David Ferrer outlasting No. 15 Jack Sock 7-6 (7), 3-6, 6-1.
Shapovalov, who just squeaked by Rogerio Dutra Silva in the first round on Tuesday, talked about how grateful he is to have reached his first Masters 1000 quarter final. With the set being brought to a tiebreak, del Potro had the upper hand when he jumped out to a 3-1 lead, looking on course to send the match into a deciding set.
Monfils, however, fended off four match points to beat Japanese world number nine Nishikori in a three-set thriller 6-7 (4) 7-5 7-6 (6).More news: Defense Minister Orders Military to Prepare for N. Korea's Tactical Provocations