MIAMI — Roger Federer knew he had things going his way at the Miami Open when he hit three shots off his frame during a wild 17-stroke exchange and still won the point because Filip Krajinovic dumped a half volley into the net.

Krajinovic quickly grabbed the ball and flipped it over the net as if continuing the rally, which drew cheers from the crowd and a smile from Federer.

"We're not robots," Federer said. "I like when players show emotion like Filip did in that instant. It was a weird, strange, ridiculous point that I got very lucky to win somehow."

A little lucky and really good, Federer won 7-5, 6-3 Monday to reach the fourth round. He improved to 14-2 this year, signalling he's a threat to win his fourth Miami title.

He'll next play No. 13 Daniil Medvedev, who won a battle of dominating serves against 6-foot-11 qualifier Reilly Opelka, 7-6 (5), 6-7 (5), 7-6 (0). There were no service breaks but plenty of aces — 19 by Medvedev and 22 by Opelka.

Among those departing in the women's fourth round were Venus Williams and Indian Wells champion Bianca Andreescu. Williams lost to No. 2-seeded Simona Halep 6-3, 6-3, and Andreescu retired with a right shoulder injury while trailing Anett Kontaveit 6-1, 2-0.

Andreescu, who is tied for the WTA lead with 20 match victories this year, said she felt pain and tightness in the shoulder.

"I've played so many matches," the 18-year-old Canadian said. "I guess it's just my body's way of telling me it has had enough. The doctor said it's nothing too serious, but the pain is there."

Andreescu said she will skip the tournament next week in Charleston, South Carolina, but plans to play the Fed Cup on April 20-21.

She called a medical timeout after the first set to receive treatment, and received similar treatment during her third-round victory over Angelique Kerber, who afterward told Andreescu she was the "biggest drama queen ever."

Andreescu defeated Kerber in the Indian Wells final on March 17 for her first career title. The injury ended Andreescu's bid to become the fourth woman to win Indian Wells and Miami back to back.

"I'm pretty upset," she said. "But I really can't complain, with what I've achieved."

Halep and Kontaveit were joined in the quarterfinals by Petra Kvitova, who faced only one break point and beat Caroline Garcia 6-3, 6-3. Kvitova, a two-time Wimbledon champion, is ranked a career-high No. 2 and will rise to No. 1 if she wins the title. No. 1 Naomi Osaka lost in the third round.

Kvitova's match was interrupted by rain for more than 90 minutes, and she took advantage.

"I had a quick nap, which was really helpful," she said.

Federer was only slightly delayed on his way to victory. Serving in the final game, he smacked aces on the first three points, and then hit another ace that skipped off the line to seal the victory — or so it was ruled.

While awaiting a replay review, Federer and Krajinovic walked to the net and discussed the call.

"He thought it was in," Federer said. "I'm thinking, 'Why did he think that?' It was quite clearly out."

Federer was correct, and when the call was overturned, he gave Krajinovic a wave as if to say, "See you in a minute." He needed only one more serve to complete the victory.

___

More AP tennis coverage: https://apnews.com/apf-Tennis and https://twitter.com/AP_Sports