SHANGHAI (AP) — Rafael Nadal lost only four points on serve Wednesday in a 6-2, 6-1 victory over Jared Donaldson in the second round of the Shanghai Masters.

The top-ranked Spaniard and No. 2 Roger Federer both advanced by winning their opening matches in straight sets.

"It was a very quick match," said Nadal, who won his sixth title of the year in Beijing last week. "I was happy to have that early break in the sixth game. After that I played a great match, not many mistakes, played aggressively."

Federer defeated Diego Schwartzman 7-6 (4), 6-4, winning the match with his 14th ace on his second match point.

"I knew going in it was not going to be easy because he's had a great run the last few weeks, months," Federer said. "He was confident. He was shaking off misses, no problems. He was serving well, making the right decisions.

"He was confident and as an opponent you can feel that. I felt that today it was going to be dangerous down the stretch of every set."

Nadal and Federer are both in contention for the season-ending No. 1 ranking, although only Nadal can clinch that honor this week. Nadal will be guaranteed to retain the No. 1 ranking through the end of the season if he wins his first career Shanghai title and Federer loses before reaching the semifinals.

Earlier, sixth-seeded Grigor Dimitrov saved three match points before finally defeating Ryan Harrison 3-6, 6-3, 7-6 (6).

The 46th-ranked Harrison led 4-2 in the third set and then 6-3 in the tiebreaker. But Dimitrov won the final five points to get through.

"I just had to be there (on those match points)," Dimitrov said. "At (my) match point, I just had to make my first serve because I knew he would go for it if not."

Also, U.S. Open finalist Kevin Anderson lost to Jan-Lennard Struff 7-6 (5), 7-6 (2), while Gilles Simon, Alexander Zverev, Sam Querrey and John Isner all advanced.