MELBOURNE, Australia — This was the sort of match, riveting and rollicking, that keeps Roger Federer in tennis — even with all of those Grand Slam titles and other accomplishments, even at age 38, even with two sets of twins to raise.

Two points from defeat at the Australian Open, in a packed house after midnight, his mind already drifting to dissecting how he lost. The trophies are the ultimate goal, of course, but winning like this is certainly special, too.

About 1 1/2 years after John Millman outlasted, and ousted, Federer in their only previous Grand Slam meeting, the 47th-ranked Australian gave the 20-time major champion all he could handle again. This time, though, Federer pulled out the victory, pushing back from way down in the final-set tiebreaker, grabbing the last six points and getting to the fourth round at Melbourne Park by edging Millman 4-6, 7-6 (2), 6-4, 4-6, 7-6 (8).

“All of a sudden you turn the whole thing around within, like, two minutes and it was so worthwhile, you know, everything that I have gone through,” Federer said.

“I think if I do play tennis, it's because of winning titles, trying to win as many matches as possible, (enjoying) myself out on court,” he continued, “but also being in epic matches like this.”

The entertaining, back-and-forth contest lasted a tad more than four hours, beginning on Friday and concluding at nearly 1 a.m. on Saturday, with roars after each point during the first-to-10 tiebreaker in the fifth set.

Federer trailed 8-4 there before rallying to snap a three-match losing skid in five-setters.

“The air gets so incredibly thin," Federer said after his record 100th match win at the Australian Open. "And you know that any overhitting, too much risk or just handing over a point at this moment will cost you dearly.”

Like Millman's four-set win over Federer in the fourth round of the 2018 U.S. Open, this one was contested in high humidity. And like back then, Millman was drenched.

After taking the fourth set this time, Millman removed and replaced his soaked socks and sneakers. When the 38-year-old Federer pushed a runaround forehand long to get broken and trail 2-1 in the final set, Millman, who's 30, plopped himself down on his sideline seat and munched on a banana.

Federer's biggest issue was his forehand, for so long one of the secrets to his success. It deserted him completely for stretches, and he finished with a whopping 48 of his 82 unforced errors from that shot.

“He pushed me to go for more. You know me: I'm not going to hold back and just rally all the time,” Federer said. “I will always try to make plays, and for that I will miss some.”

But that forehand also helped him deliver the final winner he would need, the one that ended things, and let Federer wag his right index finger in the air.

Moments earlier, three consecutive amazing shots — once-in-a-lifetime type shots — by Millman pushed him ahead 8-4 in the final tiebreaker: a backhand stop volley, followed by a pair of forehand passing winners.

It wasn't enough.

“That's what the best players, I guess, do,” Millman said of Federer's comeback. “I'll have to go back and watch it.”

Talk about a close call. But, all in all, on a day of big happenings in the women's bracket — Serena Williams lost; 15-year-old Coco Gauff beat defending champion Naomi Osaka — there wasn't nearly as much upheaval in the men's draw.

The most noteworthy upset, at least by seeding, was No. 32 Milos Raonic's 7-5, 6-4, 7-6 (2) victory over No. 6 Stefanos Tsitsipas, a semifinalist here a year ago.

Raonic hit 19 aces among his 55 winners and this is how Tsitsipas described dealing with that big serve: “You're just there, getting punched in the face with one shot."

While Raonic has been overtaken in the rankings — and in terms of fan and media attention — by a couple of younger Canadians, Denis Shapovalov and Felix Auger-Aliassime, the 2016 Wimbledon runner-up is the one headed to Week 2 in Australia.

It's nothing new for the 29-year-old Raonic, who has been a semifinalist once and a quarterfinalist three times at Melbourne Park.

Like Raonic, his next foe's game is built on a stinging serve: Marin Cilic, the 2014 U.S. Open champion and twice a Grand Slam runner-up to Federer, including at the Australian Open two years ago.

The unseeded Cilic emerged with a second consecutive five-set win, getting past No. 9 Roberto Bautista Agut 6-7 (3), 6-4, 6-0, 5-7, 6-3.

Federer now faces another unseeded opponent, Marton Fucsovics, who ended the surprising run of 22-year-old American Tommy Paul 6-1, 6-1, 6-4.

Earlier in the tournament, Fucsovics beat 20-year-old Shapovalov and 18-year-old Jannik Sinner.

Defending champion Novak Djokovic moved closer to a record eighth championship in Melbourne, and 17th Slam title overall, with a quick 6-3, 6-2, 6-2 win against Yoshihito Nishioka.

Next for Djokovic is No. 14 Diego Schwartzman, a 6-2, 6-3, 7-6 (7) winner over No. 24 Dusan Lajovic.

The other matchup with a quarterfinal berth at stake on the bottom half of the men's draw is 100th-ranked Tennys Sandgren against No. 12 Fabio Fognini.

Sandgren — whose best Grand Slam showing was a quarterfinal appearance at the Australian Open in 2018 — topped Sam Querrey 6-4, 6-4, 6-4 in an all-U.S. matchup.

Fognini beat No. 22 Guido Pella 7-6 (0), 6-2, 6-3.

“He's a character, man,” Sandgren said about Fognini. “What you see is what you get."

___

Follow Howard Fendrich on Twitter at http://twitter.com/HowardFendrich

___

More AP Tennis: https://www.apnews.com/apf-Tennis and https://twitter.com/AP_Sports