Roger Federer overcame a second set wobble to beat home player Daniel Brands 3-6 6-3 6-2 on his return to action at the German Tennis Championships.
The Swiss world number five, playing at the Hamburg claycourt event with a new, larger racket, was forced to dig deep before coming through to set up a last 16 showdown with Jan Hajek.
Federer broke Brands once in the opening set but allowed his German opponent back into the match in the second when he relinquished serve for the first time.
But the four-time winner of the event showed his class in the decider, much to his relief.
"It was a tough match, Daniel is playing a very good season," Federer said.
Federer will play Czech qualifier Hajek in the next round after he overcame 15th-seeded Ernests Gulbis of Latvia 6-4 2-6 6-4.
Home favourite Tommy Haas was a popular 6-1 4-6 6-4 winner over Blaz Kavcic, while fourth-seeded Jerzy Janowicz, a Wimbledon semi-finalist, prevailed 6-4 3-6 7-6 (7/4) over Robin Haase of the Netherlands.
Defending champion Juan Monaco survived a tough opener against Gael Monfils 6-4 6-4, however seeded quartet Andreas Seppi, Tommy Robredo, Mikhail Youzhny and Martin Klizan all bowed out.
Feliciano Lopez, Fabio Fognini and in-form Fernando Verdasco advanced.