The top seed and world number three bounced back after wildcard Hanfmann - ranked 118th in the world - took the first set via a lengthy tiebreaker.
Zverev eventually posted a 6-7 (12/14) 6-4 6-2 victory and will face another compatriot in the next round in Jan-Lennard Struff, who beat another German, Yannick Maden, 6-3 3-6 6-3.
South Korea's fourth seed Hyeon Chung progressed as he also overcame a German wildcard, easing past Matthias Bachinger 6-1 6-1.
He now takes on Slovakian qualifier Martin Klizan, who won 4-6 6-3 7-5 against Bosnia's Mirza Basic.
At the the Millennium Estoril Open in Portugal, fourth seed Gilles Muller, last year's beaten finalist, suffered a round-two exit as the man from Luxembourg was beaten 6-4 7-5 by American Frances Tiafoe.
Tiafoe's next opponent will be Italy's Simone Bolelli, a 3-6 7-5 6-2 victor over Federico Del Bonis of Argentina.
Third seed Kyle Edmund booked his place in the last eight, the British number one getting past 19-year-old Australian Alex de Minaur 6-2 7-5.
He now meets Joao Sousa, who emerged victorious from an all-Portuguese clash with Pedro Sousa, winning 4-6 7-6 (7/1) 7-5.
Three seeds crashed out in the second round of the TEB BNP Paribas Istanbul Open, with Andreas Seppi, Aljaz Bedene and Viktor Troicki all being eliminated.
Third-seeded Italian Seppi lost 6-3 6-7 (4/7) 6-3 to Serbian Laslo Djere, while Slovakia's Bedene (fourth) and Djere's compatriot Troicki (sixth) were defeated in straight sets by Taro Daniel of Japan and Brazilian Rogerio Dutra Silva respectively.
There was safe progress made by the fifth seed, Seppi's compatriot Paolo Lorenzi, as he beat Argentinian Marco Trungelliti 6-2 7-6 (7/5).
Related tennis links