Federer took out Bautista Agut, while Shapovalov ousted Mannarino. (AP)

MONTREAL (AP) — Roger Federer advanced to the semifinals of the Rogers Cup and was joined later Friday by Canadian teenager Denis Shapovalov, who followed his upset of Rafael Nadal with another three-set victory.

Shapovalov beat 2009 U.S. Open champion Juan Martin Del Potro in the second round and then knocked off the top-seeded Nadal in a third-set tiebreaker on Thursday in the round of 16.

He broke service for a 2-1 lead in the third set Friday only to hand it back in the next game, but a roar went up when Mannarino wasted a chance to put away a game point and Shapovalov jumped on the chance to break for a 5-4 lead. He leapt in the air as he closed out the match.

"I've been against the wall a couple times this week and I'm very happy I've come out several times just playing really good tennis in those situations," Shapovalov said. "I think it really shows how I've improved mentally, along with just finding my game at the right moments."

After facing a run of veterans, he will be up against the 20-year-old Zverev, who beat Kevin Anderson of South Africa 7-5, 6-4.

The second-seeded Federer continued his mastery over 12th-seeded Roberto Bautista Agut of Spain with a 6-4, 6-4 victory. The 36-year-old Swiss will next face unseeded Dutchman Robin Haase, a 4-6, 6-3, 6-3 winner over Diego Schwartzman of Argentina.

Federer has won all seven career matches and taken all 16 sets against the 29-year-old Bautista Agut.

He is 1-0 against Haase after a straight-sets win in Davis Cup play in 2012.

Federer said he knows Haase well from serving with him on the ATP player council and from practicing together.

"I'm looking forward to a tough match because he can serve very well and he mixes up his tactics a lot," Federer said. "Sometimes he tends to just roll the ball in and use the big serve, or he uses a slice a lot and comes in.

"So I don't quite know with Robin what I'm going to get. But, as I have practiced with him quite a bit, maybe I am better prepared than if I would have never hit with him before."

Federer broke serve for a 5-4 lead in the first set and broke again for 2-1 in the second en route to the victory in a little more than an hour. Federer was coming off a three-set win over another Spaniard, David Ferrer, against whom he is 17-0.

"My game plan worked better against Bautista Agut than against Ferrer," he said. "I believe it's because I was more aggressive coming to the net."

Haase, who upset seventh-seeded Grigor Dimitrov in the third round, reached his first career Masters Series semifinal. The 30-year-old Haase, back to 52nd in the world after battling injuries for much of his career, improved to 5-0 against 36th-ranked Schwartzman.

"I played a lot of good matches, especially against Dimitrov," said Haase. "It's tough to come back and play that same level.