Melbourne, Australia — After wasting three chances to serve it out, then saving three match points, Simona Halep finally fended off American Lauren Davis in a third-round win that took 3 hours, 45 minutes and equaled a record at the Australian Open.

For top-ranked Halep, already playing with an injured left ankle, the 4-6, 6-4, 15-13 victory on Saturday was a testament to her renewed self-belief.

The third set took 2:22 and momentum swung, with 11 service breaks and two medical timeouts — for Davis to get treatment for toes on both feet — before Halep converted on her first match point.

Halep had chances to serve for the match in the 9th, 11th and 15th games of the third set but was broken each time by the No. 76-ranked Davis, who then blew three match points from 0-40 on Halep’s serve in the 22nd game.

“Definitely was a very tough match, so long,” said Halep, who has twice reached the final at the French Open but never won a Grand Slam singles title. “I never played the third set so long, so I’m really happy I could stay and win it. I’m almost dead.”

It equaled the longest women’s singles match at the Australian Open in terms of games played: Chanda Rubin’s win over Arantxa Shanchez Vicario in 1996 was also 48 games. In terms of duration, it was almost an hour shorter than the record 4:44 that Francesca Schiavone needed to beat Svetlana Kuznetsova in 2011.

“I just feel that my muscles are gone,” said Halep, who badly twisted her left ankle in the first round. “My ankle is, I don’t know how it is because I don’t feel it anymore! But … it was nice to win this match.”

Halep, who lost in the first round here in 2016 and last year, said she was mentally stronger now.

“I was down love-40. She had three match balls. It was not easy, but I just kept playing. I just kept believing that it’s not over,” Halep said. “For sure I’m stronger mentally, and I could resist like for every moment in the match. That makes me very happy, and I think the big win is that I could handle it.”

Davis lost the three previous times she’d played in the third round of a major, but did everything possible to stay in the match, keeping long rallies alive to put pressure on Halep.

The 24-year-old American finished with roughly twice the number of winners (52 to 27) against slightly more than double the unforced errors (73-39), and broke Halep’s serve six times.

“We were both fighting our hearts out. Every point was super long,” Davis said. “I got to the point where I was so tired, I just told myself to swing and move. I didn’t feel any pressure.”

Halep will play the winner of the later match between local hope Ashleigh Barty and Naomi Osaka.

U.S. Open finalist Madison Keys advanced 6-3, 6-4 over Ana Bogdan and will next play No. 8 Caroline Garcia, who beat Aliaksandra Sasnovich 6-3, 5-7, 6-2.

Sixth-seeded Karolina Pliskova had 11 aces and beat No. 29 Lucie Safarova 7-6 (6), 7-5 in a match featuring just one service break.

The 17th-seeded Keys, who lost in the U.S. Open final last year to Sloane Stephens, saved three break points serving for the match, finally clinching it on her first match point when Bogdan netted a backhand.

Keys missed last year’s Australian Open after undergoing surgery to repair her injured left wrist. She then played only one match after the U.S. Open before shutting down her season early to let the wrist heal. It’s helped her start the new season feeling mentally fresh, as well.

“I finished the U.S. Open and I was exhausted,” she said. “So as amazing as that run was, the combination of being exhausted from that and having a wrist that still wasn’t 100 percent perfect, I just needed to kind of shut it down, calm down, and then I was really excited to start the new season.”

On the men’s side, fifth-seeded Dominic Thiem beat Adrian Mannarino 6-4, 6-2, 7-5 to move into the fourth round for a sixth consecutive major.