Roger Federer saved two match points against France's Benoit Paire to avoid an upset 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.