NEW YORK CITY, NY, USA - No.10 seed Jelena Ostapenko weathered a mid-match letdown - and tough weather conditions against a motivated opponent - to knock out Andrea Petkovic in three sets at the US Open, 6-4, 4-6, 7-5.

“The way I finished the match, I'm glad,” Ostapenko said. “I had more opportunities, especially I won first set and 3-0 up. Then my game level dropped a little bit.

“But my opponent, she was playing very well today. I had really to win, like, every point. She was fighting till the end. And I'm happy when, in the third set, I was 5-4, 30-15 and serving. Then I lost until 5-All. But I'm happy that I was fighting till the end and I managed to win the match.”

Read more: Kvitova moves past Wickmayer in US Open first round

The former French Open champion came into the year’s last Grand Slam with an 0-2 record on the North American hardcourts after posting first-round losses in Montreal and Cincinnati, adding to her total of eight opening round losses throughout the season.

She set out strongly to reverse that trend against Petkovic, a former Top 10 player and quarterfinalist here in Flushing Meadows. The German was going for her fourth straight win at a Grand Slam - a feat she had only accomplished once in her career back in 2011.

Ostapenko had to fight her way back into the first set twice as Petkovic made a roaring start to claim an early break at 1-0 and then again at 3-2. Both times Ostapenko employed her aggressive game to win the baseline battles, and a late break at 6-4 sealed the set for the Latvian.

But Petkovic didn’t stay down and out in the second set despite starting with a 0-3 break deficit. The former Top 10 player patiently waited for her chances, and she was rewarded as Ostapenko started to misfire. Petkovic capitalized on a double fault and slew of unforced errors to finally break through at 5-4, sealing the set with an ace to take them the distance.

It was Ostapenko who came away with the lead after weathering three straight breaks of serve, and was rapidly closing in on the set with a 5-2 lead when Petkovic found another gear. With Ostapenko serving for the match, Petkovic saved two match points to get the break back and swing the momentum - and the boisterous crowd - back in her favor.

But the Latvian quickly slammed the door shut a few games later, breaking Petkovic in the final game and converting her fourth match point to put an end to the grueling encounter after two hours and 18 minutes.

“The conditions were difficult today, it was very humid and also very hot, but it was the same for both of us I mean, we had to deal with it,” Ostapenko said. “When I came after this 10-minute break [the extreme heat rule], I felt actually a bit better, because I was in air conditioning, and then I came back and I felt like it's not that hot anymore.

“I think it helped me, because then I went back on court and I broke her serve straightaway.”

Up next, Ostapenko will face Taylor Townsend in the next round after the American knocked out wildcard Amanda Anisimova, 3-6, 6-4, 6-3.