Nadal didn’t get it all his own way in an afternoon match on Rod Laver Arena, needing five match points and 2 hours, 42 minutes to beat Hanfmann.
The sixth-seeded Nadal, aiming for a men’s record 21st Grand Slam singles title, had two match points on Hanfmann’s serve in the ninth game of the third set and then two more on his own in the next game before finally clinching a spot in the third round when his rival sent a forehand long.
Nadal converted four of his 16 break-point chances, including one of eight in the third set, but faced only two break points on his own serve and fended them both off.
“I knew him before, I played against him in the first round at Roland Garros — I know he’s dangerous,” Nadal said. “Today his level of tennis was much higher than what his ranking says, without a doubt.”
Federer is skipping the Australian Open while he continues his recovery from injury. Djokovic, a nine-time champion at Melbourne Park, was deported after an 11-day saga that he ultimately lost because he didn’t meet Australia’s strict COVID-19 vaccination regulations.
In other second-round matches, No. 23 Reilly Opelka had a 6-4, 6-3, 7-6 (4) win over Dominik Koepfer; No. 19 Pablo Carreno Busta beat Tallon Griekspoor 6-3, 6-7 (6), 7-6 (3), 3-6, 6-4; and No. 31 Carlos Alcaraz beat Dusan Lajovic 6-2, 6-1, 7-5.
The Associated Press contributed to this report.