The Swiss maestro avoided a stunning upset, but Serena Williams, Naomi Osaka and Stefanos Tsitsipas weren't so lucky.
Williams crashed out at the hands of Wang Qiang in three sets, while Osaka was beaten in two by 15-year-old Coco Gauff.
Tsitsipas went out in straight sets to Milos Raonic, while Marin Cilic saw off No. 9 seed Roberto Bautista Agut in five.
Novak Djokovic and Ashleigh Barty were also in action and picked up wins over Yoshihito Nishioka and Elena Rybakina, respectively.
Select Men's Singles Matches
(2) Novak Djokovic bt. Yoshihito Nishioka, 6-3, 6-2, 6-2
Marin Cilic bt. (9) Roberto Bautista Agut, 6-7 (3), 6-4, 6-0, 5-7, 6-3
(3) Roger Federer bt. John Millman, 4-6, 7-6 (2), 6-4, 4-6, 7-6 (8)
(32) Milos Raonic bt. (6) Stefanos Tsitsipas, 7-5, 6-4, 7-6 (2)
(14) Diego Schwartzman bt. (24) Dusan Lajovic, 6-2, 6-3, 7-6 (7)
Select Women's Singles Matches
(1) Ashleigh Barty bt. (29) Elena Rybakina, 6-3, 6-2
(27) Wang Qiang bt. (8) Serena Williams, 6-4, 6-7 (2), 7-5
Coco Gauff bt. (3) Naomi Osaka, 6-3, 6-4
(7) Petra Kvitova bt. (25) Ekaterina Alexandrova, 6-1, 6-2
(22) Maria Sakkari bt. (10) Madison Keys, 6-4, 6-4
A bright start from Millman saw him go a break up early in the first set.
Federer eventually hit back when the Australian was serving for the set, but Millman responded by breaking the Swiss to love in the following game to draw first blood.
The pair kept things on serve in the second, before Federer won the tiebreaker.
It remained a hard-fought contest, though. Federer eventually broke Millman late in the third, but not before his opponent had avoided a break in the eighth game thanks in part to a superb backhand passing winner at the culmination of a 27-shot rally.
Federer continued to struggle for rhythm in the fourth. While he had particular trouble on his forehand, Millman had no such trouble and the 30-year-old claimed the decisive break midway through the set with some excellent winners.
The pair exchanged breaks early in the fifth, before grinding to a 10-point tiebreaker.
Millman raced to a 3-0 lead and then battled to 8-4, producing this fine winner along the way:
He needed just two points to claim a memorable win over the 20-time Grand Slam winner, but Federer rattled off six consecutive points—helped by a pair of errors from his opponent—to snatch a victory.
Williams gave up just one game against Wang when they met in the quarter-finals of the U.S. Open last year, but it was a different story this time around.
The 38-year-old made 56 unforced errors while Wang, 10 years her junior, made just 20.
The Chinese player went a set and a break up before Williams fought back to force a decider:
It stayed on serve in the third set until Wang broke serve in the final game to win the match:
Williams remains on the hunt for her 24th Grand Slam title, having last won one in Melbourne in 2017, while Wang will face Ons Jabeur in the next round following her victory over Caroline Wozniacki.
Osaka ended Gauff's run in last year's U.S. Open at this stage, and the American returned the favour in Melbourne:
Gauff hit just six winners in her 67-minute win, but the defending champion handed her 30 points via unforced errors.
As impressed as Christopher Clarey of the New York Times was with Gauff, Osaka was well below her usual level:
Gauff will face either Sofia Kenin for the first time in the fourth round.
Djokovic was untroubled in his three-set win over Nishioka, bagging 40 winners and 17 aces along the way.
Tennis writer Tumaini Carayol put his serving in perspective:
Overall, he lost just eight points on his own serve in the entire match, two of them from double-faults.
Djokovic will face No. 14 seed Diego Schwartzman following his straight-sets victory over Dusan Lajovic.