MIAMI, FL, USA -- No.2 seed Simona Halep of Romania came back from the brink at the Miami Open on Sunday, edging past lucky loser Polona Hercog of Slovenia, 5-7, 7-6(1), 6-2, to squeak into the fourth round.

"It was not easy at all," Halep said, during her post-match press conference. "I think the level was very, very high. [Hercog] played unbelievable. If she keeps playing like this, she can be Top 20 easy. I think it was a great match for both of us. I'm really happy I could win it in the end. It was a lot of effort today."

World No.93 Hercog had beaten Halep in their only previous encounter, but that came a decade ago at a Challenger event in Sofia. Nevertheless, Hercog was a tiebreak win away from retaining her undefeated record against Halep, before the former World No.1 turned the match around and claimed the grueling win after two hours and 49 minutes of play.

Photos: Miami in motion: That Friday feeling with Halep, Osaka, Kerber and more

Each player won 69 percent of points on their first serves, though Halep got 73 percent of her first serves into play, while Hercog got just slightly over half of those into the box. Halep was also more effective on her second serve, and she held 13 break points during the encounter, converting four of those chances to eke out the victory.

"First two sets were tough because [Hercog] was serving very, very strong," Halep continued. "Also both shots, forehand, backhand, slice actually, it was really tough to get some points. She didn't miss. So it was really difficult. It was a very, very high standard."

World No.3 Halep, whose best Miami result is a semifinal loss to Serena Williams in 2015, now finds herself in the round of 16 for the fourth time in the last five years. There, she will face three-time Miami Open champion Venus Williams, who dispatched No.14 seed Daria Kasatkina on Sunday. They have split their six meetings, but Halep has won their last three matches after losing the first three.

"It's always tough against Venus," Halep admitted. "I'm not going to say that it's going to be easier because I won the last matches against her."

"I will be motivated," Halep added. "I will be ready to play. Hopefully I will be 100 percent tomorrow. Why not, I will believe that I have the chance. Still, I will stay focused."

Halep’s forehand went awry on multiple occasions early in the match, and Hercog took initial advantage, garnering the first break to lead 2-1. The Slovene used strong serving and brilliant touch at the net to extend her lead to 4-2.

But after Halep held for 4-3, the Romanian struck back, using a beautiful backhand on break point to level the set at 4-4. Another backhand winner consolidated the break in the next game, putting Halep just one game away from a one-set lead.

Hercog, however, was unfazed, and after she held for 5-5, the Slovene broke Halep at love, as the forehands began to get away from the No.3 seed once more. Now serving for the set at 6-5, Hercog fended off a break point with an error-forcing forehand at the end of a rally, and then used more stellar serves to power through the game and clinch the opening frame.

The intensity of the tight affair ramped up throughout the second set, as neither player faced a break point up through 4-3. But in that game, Halep used her superior retrieving skills to clinch a service break on her fourth opportunity, after back-to-back long forehand errors by Hercog.

Hercog, though, immediately struck back, cruising through the next game with outstanding volleying to get right back on serve. After Hercog held for 5-5 with an ace and 6-6 with a drop volley winner, Halep found herself with her back against the wall, facing a potentially event-ending tiebreak.

Halep, however, raised her game when it mattered most. A backhand winner brought the Romanian to 3-0 in the breaker before consecutive fierce forehands forced errors from Hercog, pulling Halep to 5-0. A forehand winner down the line gave Halep a 6-1 lead and five set points; she converted the first with another forehand winner, and the match was tied.

Halep maintained her momentum from the tiebreak at the start of the decider, staving off a break point with a deep forehand en route to a hold for 1-1, then using more outstanding depth on her shots to clinch a crucial service break for a 2-1 lead.

The Romanian needed to evade another break point before holding for 3-1, but once she got out of that jam, Halep cruised through the remainder of the match. More strong returning led to a second break and a 5-2 lead, and Halep had no problems serving out the match, finishing the nail-biting affair with aplomb.