The world number three, who dropped out of last month's French Open, had little trouble swatting aside Tunisia's Malek Jaziri, 6-3, 7-5, and next faces Belgium's David Goffin.
Federer, who is in the twilight of a sparkling career and turns 35 in August, is chasing a ninth title in Halle, Germany.
He has yet to win a title in 2016, his longest drought to start a year since he went title-less in 2000.
"I was happy to come through a tough match because I thought he's tough to play against. I struggled to read his technique, the way he gets into the ball I can't really tell where he goes and I remember that from the last time I played him in Dubai, I remembered there was something but not until I got on the court. So, it was tough. I think he's a good player.
Also Read
Goffin set up the meeting with Federer after Ukraine's Sergiy Stakhovsky retired from their clash when trailing 4-6, 7-5, 2-0.
Federer leads Goffin 4-0 in their career head-to-heads, including a 6-2, 6-1, 6-4 win in this year's Australian Open fourth round. Also into the next round is home hope Philipp Kohlschreiber, the eighth seed, who beat Ivo Karlovic of Croatia 6-7 (7/9), 6-4, 7-5.