Japan's Kei Nishikori weathered a barrage of aces from towering Croat Ivo Karlovic on Thursday to advance to the third round of the men's singles at the Australian Open, while compatriot Naomi Osaka also advanced to the round of 32 in the women's bracket.

In a match that lasted nearly four hours in the Melbourne heat, Nishikori rallied in the decider after giving up a two-set lead to clinch a 6-3, 7-6(6), 5-7, 5-7, 7-6(7) victory. He scraped the win in the decider via a 10-point tiebreaker, introduced at this year's tournament.

"I think this match will help (boost) my confidence. It was a great match," Nishikori said. "I think we both played great tennis, and of course he served really well today. I'll try to carry this confidence into the next match."

Despite the massive deficit on serve -- Karlovic rocketed 59 aces to Nishikori's nine -- the Japanese appeared to have rounded into better form than he displayed in his narrow first-round victory over Polish qualifier Kamil Majchrzak, who retired with injuries midway through the fifth set Tuesday.

But in the face of Karlovic's advantage on serve, the world No. 9 was able to work his way into the match.

The 73rd-ranked player slammed eight aces over his first four service games at Margaret Court Arena, but the 29-year-old from Shimane Prefecture wrapped up the opening set in under 30 minutes, breaking his opponent's serve to take a 5-3 lead before closing the stanza with decisive service game topped with a forehand winner on set point.

The Croatian's big serve continued to give Nishikori fits in the second set, with Karlovic sending down 16 aces, but he committed twice as many unforced errors as Nishikori won in a tiebreaker.

The pair traded games again in the third set, but Karlovic, 10 years Nishikori's senior, broke the eighth seed's serve to go up 6-5, and served out the set.

In the fourth, Nishikori had a chance to pull ahead in the eighth game, but failed to capitalize on two break point chances. Karlovic broke to love with the score at 5-5 and won the set with four straight aces.

Nishikori had to dig himself out of a 0-40 hole at 4-4 in the fifth set, and the match went to yet another tiebreaker from which he prevailed by winning the final four points.

"He almost had it, for sure. Just one more point and it could have went his way," Nishikori said.

"It was a really tough match," Nishikori said. "It could have went both ways. I was down 7-6 in a tiebreaker, but I returned well and I focused well over the last couple of points. I'm very happy to win today."

After the match, Nishikori marveled at the 211-centimeter Karlovic's serve, pointing out that in one match the Croat racked up nearly a year's worth of aces for him.

"It's never easy, of course, and frustrating if you can't (return) serve three times in a row."

"But I think I focused well. The third and fourth sets were really tough. I lost two easy games and he got the sets. I had to reload again the fifth set. (It was a) really tough match today."

Last year, Nishikori missed the season's first Gram Slam when a right wrist injury suffered in August 2017 wiped out the start of his season. He reached the final 16 in 2017, but was defeated by Roger Federer in five sets, and is still looking to get past the quarterfinals of the Australian Open for the first time.

Later Thursday on the same court, Osaka defeated Slovenian Tamara Zidansek in straight sets to book a spot in the third round of the women's singles.

Osaka, the fourth seed, needed just over an hour to beat Zidansek 6-2, 6-4 in their first match-up, but had to mount a second-set comeback to secure the win.

"I thought I served pretty well, but I got broken twice and she was a really great opponent," Osaka said. "This was my first time playing her, so I'm just really happy to be win to be honest."

After Zidansek broke Osaka's serve in the first set and leveled 2-2 on three straight unforced errors, the world No. 4 upped her game and broke the Slovenian twice while claiming four straight games to go out in front.

The 21-year-old Japanese found herself trailing 4-2 in the next set, but turned the set around by breaking Zidansek twice.

In the third round, Osaka will face Taiwan's Hsieh Su-wei, against whom she holds a 1-0 record.

"I know that she's really great and she's been playing really well recently, so I hope that it's exciting," Osaka said of her third-round opponent.

Osaka was knocked out in the fourth round in her first Australian Open appearance last year. In September, she defeated 23-time major champion Serena Williams at the U.S. Open to become the first Japanese player to win a Grand Slam.

Among other Japanese players, Taro Daniel lost 6-3, 7-6(2), 6-3 to Canadian 25th seed Denis Shapovalov.

Daniel, ranked 78, advanced to the second round after his opening opponent, Australian qualifier Thanasi Kokkinakis, retired hurt in the second set of their match on Tuesday.