Jessica Pegula’s three-peat bid at the Canadian Open ended Friday in Montreal.

Thirty-five-year-old Anastasija Sevastova threw down a stunning 3-6, 6-4, 6-1 victory over the No. 3 seed and two-time defending champion at the Omnium Banque Nationale.

No. 386 in the PIF WTA Rankings, Sevastova was granted entry into the main draw with a protected ranking after suffering a challenging knee injury. She’s the lowest-ranked player to beat a Top 10 player since Angelique Kerber surprised Jelena Ostapenko more than a year ago at Indian Wells.

What happened, exactly?

Hot shot: Sevastova foils Pegula in Montreal with ridiculous defense

“I don’t know,” Sevastova said in her on-court interview. “Somehow, I was down 2-0 in the second set and started to play better and better. Third set, I played really good.

“Just trying to stay on the court as long as possible.”

The Latvian was playing only her 24th WTA Tour-level match in the past four years and had lost her last seven meetings against Top 5 opponents. It’s been seven years since she managed that feat, at the 2018 US Open, defeating Sloane Stephens in what remains her best Grand Slam singles result.

It’s also been four years since she’s won three matches in a row.

Sevastova can equal her best career result in Canada with a win Sunday against Naomi Osaka, a 6-2, 6-4 winner over Jelena Ostapenko. Osaka has won three matches here, including in the second-round when she saved two match points against Liudmila Samsonova. Sevastova reached the quarterfinals in 2018.

This is Sevastova’s first Round of 16 at a WTA 1000 since Madrid 2021.

Meanwhile, No. 6 seed Madison took care of business, coming back to defeat fellow American Caty McNally 2-6, 6-3, 6-3 in 2 hours and 15 minutes.

Keys is now 9-3 in Montreal and Sunday will play the winner of the later match between No. 11 seed Karolina Muchova and Belinda Bencic.

Keys converted her third match point with a massive forehand pass, breaking McNally for the fourth time.

“Today I did a good job of bouncing back after the first set,” Keys said. “Let go of the first set and move on. Happy I was able to do that.”

That ended a run of 12 consecutive match-wins for McNally, including titles in Newport at WTA-125 level and in Evansville in ITF. McNally is now 0-7 in her career against Top 20 players.

Pegula played a terrific first set, breaking Sevastova in the first and last games of the frame, while not facing a break point herself.

The second was more complicated as Sevastova surged to a 4-2 lead. Pegula leveled it at 4-all, but Sevastova broke through again for a 5-4 lead and, saving three break points in the process, served it out.

Considering her age and the nature of her first two wins here, Sevastova played a remarkable third set. Victories over Ajla Tomljanovic and No. 25 seed Magda Linette required a draining three sets.

Sevastova scored two service breaks against Pegula to lock it up. She was better in the big moments, saving nine of 13 break points and converting six of 10.

After winning the title in Bad Homburg, Pegula has lost three of four, including early exits at Wimbledon, Washington, D.C. and Montreal. She finished with 63 unforced errors, her most in a match this season.