KEY BISCAYNE, Fla. (AP) — Simona Halep knows being ranked No. 1 doesn't make it any easier to win matches.

Halep, of Romania, struggled to post a 3-6, 6-3, 7-5 second-round win over French lucky loser Oceane Dodin in their first career meeting at the Miami Open on Thursday.

Halep allowed the 98th-ranked Dodin to break her serve on six of seven opportunities she presented in the match, which lasted more than two hours.

"I played bad, but you have these days, and when you don't give up, is the most important thing," said Halep, who broke a racket in frustration during the match. "I think that's why I won today, because I didn't give up."

Halep broke Dodin's serve for the seventh time at 4-4 in the third set before closing it out.

"Before, maybe in previous years, I couldn't win the matches in the third set, so I'm really happy that I changed this and I feel stronger," Halep said. "So when I go to the third set, I don't panic."

Halep played in her third career Grand Slam final at the Australian Open in January, but has yet to secure a Grand Slam trophy.

Halep's best Miami Open was reaching the 2015 semifinals.

Also Thursday, former No. 1 Angelique Kerber of Germany advanced to the third round with a 6-2, 6-2 win over Johanna Larsson of Sweden.

Kerber is 19-4 this year and has reached at least the quarterfinals of all five tournaments she's played.

Kerber, the 2016 Australian Open and U.S. Open champion, won her first tournament since that U.S. Open at Sydney in January. She also reached the Australian Open semifinals.

Two-time Miami champion Victoria Azarenka also advanced. She was leading Madison Keys 7-6 (5), 2-0 when the 14th-seeded Keys retired with a left hamstring injury.

The 186th-ranked Azarenka is playing on a wild card. It's her fourth tournament since her son, Leo, was born in December 2016. She reached the second round at Indian Wells earlier this month.

"I think I raised my level compared to Indian Wells pretty dramatically," Azarenka said. "I want to continue to just improve.

"But it's going to take time."