Roger Federer struggled in his first match since his Wimbledon humiliation when he had to come back from a set down to defeat Germany's Daniel Brands in his Hamburg opener on Wednesday.
The 31-year-old, top-seeded Federer won 3-6, 6-3, 6-2 against the world number 58, who was celebrating his 26th birthday, to reach the third round of a tournament he last played in 2008.
It was his 30th career win at the tournament.
"I think it was good for me to have a tough match like this and come through at the end," said Federer.
"Clearly these kind of matches are always important, especially losing the first set makes things difficult. You're not allowed to make many more unforced errors in crucial moments and I was able to come through and play better as the match went on. That's always encouraging for the next round."
Federer, now ranked five in the world, his lowest point for a decade, goes on to face Jan Hajek of the Czech Republic for a quarter-final spot.
The Swiss great is using this event and the Gstaad tournament, which starts on July 22, to bounce back from his shock Wimbledon exit ahead of next month's US Open.
Federer crashed out of Wimbledon, where he was the seven-time champion, at the hands of Ukraine's 116-ranked Sergiy Stakhovsky in his worst Grand Slam defeat for a decade.
The second round loss ended his run of 36 consecutive Grand Slam quarter-final appearances, having not gone out of a major before the last eight since the 2004 French Open.
Hajek reached the third round with a 6-4, 2-6, 6-4 win over Latvian 15th seed, Ernests Gulbis.
Tommy Haas, who first competed at Hamburg in 1997, will play in-form Carlos Berlocq in the third round.
Second seed Haas was made to work hard for a 6-1, 4-6, 6-4 victory over qualifier Blaz Kavcic of Slovenia.
Last week's Swedish Open champion, Berlocq, continued his run of form by beating Slovak 16th seed Martin Klizan 4-6, 6-1, 7-6 (7/5).
Argentine fifth seed Juan Monaco got his title defence off to a winning start when he beat Gael Monfils 6-4, 6-4 in 73 minutes for a place in the third round.
Qualifier and world number 114 Federico Delbonis held his nerve to knock out 2006 champion Tommy Robredo, the 10th seed, 6-1, 4-6, 6-4.
Guillermo Garcia-Lopez improved to 5-1 in his head-to-head record against 13th seed Mikhail Youzhny in a 6-3, 6-7 (3/7), 6-2 win.
Youzhny saved six match points in the second set.
Results from the ATP Hamburg tournament on Wednesday (x denotes seeding):
Roger Federer (SUI x1) bt Daniel Brands (GER) 3-6, 6-3, 6-2
Jan Hajek (CZE) bt Ernests Gulbis (LAT x15) 6-4, 2-6, 6-4
Feliciano Lopez (ESP x11) bt Jan-Lennard Struff (GER) 7-5, 6-3
Jerzy Janowicz (POL x4) bt Robin Haase (NED) 6-4, 3-6, 7-6 (7/4)
Fernando Verdasco (ESP x14) bt Roberto Bautista (ESP) 6-4, 3-6, 6-2
Federico Del Bonis (ARG) bt Tommy Robredo (ESP x10) 6-1, 4-6, 6-4
Juan Monaco (ARG x5) bt Gael Monfils (FRA) 6-4, 6-4
Guillermo Garcia-Lopez (ESP) bt Mikhail Youzhny (RUS x13) 6-3, 6-7 (3/7), 6-2
Marcel Granollers (ESP) bt Andreas Seppi (ITA x6) 6-2, 1-6, 6-1
Fabio Fognini (ITA x12) bt Albert Ramos (ESP) 6-1, 6-3
Carlos Berlocq (ARG) bt Martin Klizan (SVK x16) 4-6, 6-1, 7-6 (8/6)
Tommy Haas (GER x2) bt Blaz Kavcic (SLO) 6-1, 4-6, 6-4