Roger Federer saved two match points to avoid an upset against France's Benoit Paire and reach the quarter-finals of the Halle Open.
Federer, the 20-time Grand Slam champion and world number one, was made to work hard by the world number 48 before winning 6-3 3-6 7-6 (9-7).
Swiss Federer, 36, missed two match points to wrap up victory without the need for a tie-break in the final set.
He faces Australian Matthew Ebden next in the grass-court tournament.
Federer, seeking a 10th Halle title, must win the event if he is to retain the world number one ranking.
He closed out the first set with successive aces but Paire rallied to lead 4-0 and take the second.
"I created quite a few opportunities, but maybe I was a bit tentative at times," said Federer, whose victory was his 18th in succession on grass.
"I was disappointed with my serve in the second set, being broken twice. That is not allowed to happen. I need to clean that up".
Victory in Halle would give Federer his 99th career title.
He will begin the defence of his Wimbledon title on 2 July.