NEW YORK — Karolina Pliskova can still win the U.S. Open and keep her No. 1 ranking, thanks to a big comeback Saturday.

Pliskova fought off a match point in the second set and rallied to beat No. 27 Zhang Shuai of China 3-6, 7-5, 6-4 to advance to the fourth round.

The runner-up last year needs to at least return to the final for a chance to remain atop the rankings when the year’s final major tournament is over, and it appeared for a while that the Czech wouldn’t get close.

But she stayed alive while trailing 4-5 in the second set, then pulled out the third after receiving treatment from a trainer on her right forearm between sets.

“Last Grand Slam of the season and knowing you played fine last year, you just want to play that good again,” Pliskova said. “I don’t feel like I’m playing that good again, but I’m still in the draw, actually, so I’m not going to be that sad.”

The top seed on the men’s side also had to rally after dropping the first set. With the roof closed at Arthur Ashe Stadium because of rain, Rafael Nadal started to find the range with his punishing shots in the second set and beat Leonardo Mayer of Argentina 6-7 (3), 6-3, 6-1, 6-4 to reach the fourth round.

Upsets have scrambled one half of the men’s bracket, but everything is mostly as expected on the other side, with Nadal, Federer, No. 6 Dominic Thiem and No. 9 David Goffin still alive.

Thiem eased into the fourth round with a 7-5, 6-3, 6-4 victory over No. 30 Adrian Mannarino of France. He will next face No. 24 seed Juan Martin del Potro. The 2009 champion swept past No. 11 Roberto Bautista Agut, 6-3, 6-3, 6-4.

French Open women’s champion Jelena Ostapenko was ousted with a 6-3, 6-2 loss to Russia’s Daria Kasatkina.

Wimbledon champion Garbine Muguruza, the No. 3 seed, and No. 4 seed Elina Svitolina can overtake Pliskova for the No. 1 ranking. Svitolina advanced to the round of 16 with a 6-4, 7-5 victory over American Shelby Rogers, who won the longest women’s match in U.S. Open history on Thursday when she beat No. 25 Daria Gavrilova in 3 hours, 33 minutes.

This one went 1:33, ending when Svitolina’s forehand hit the tape and barely fell over the net onto Rogers’ side.

Pliskova, who fell to Angelique Kerber in the 2016 final, would need to win the tournament if Muguruza reaches the semifinals and loses.

If Muguruza advances to the final, Pliskova would lose the No. 1 ranking even if she wins the tournament.

“It’s not only about the points, but I just felt I really can play well here,” said Pliskova, who will next face American Jennifer Brady.

Another American advanced, as No. 20 seed CoCo Vandeweghe outlasted No. 10 Agnieszka Radwanska of Poland 7-5, 4-6, 6-4.