World number one Roger Federer kept his quest for a 10th Halle grasscourt title alive by saving two match points to defeat France's Benoit Paire 6-3, 3-6, 7-6 (9/7) and make the quarter-finals on Thursday.
Federer will face Australia's world number 60 Matthew Ebden, who defeated Germany's Philipp Kohlschreiber 4-6, 6-1, 6-2, for a place in the semi-finals.
Federer's preparations in the build-up to the defence of his Wimbledon title had been running smoothly, with a title last week in Stuttgart and a solid opening Halle win for the top seed.
It was a tough fight on Thursday, however, with the 36-year-old missing two match points in the final-set tiebreak and then saving two for Paire.
The top seed finally won on his third match point when Paire returned long.
Federer, who won the opening set with back-to-back aces, fell 4-0 down in the second set as Paire rallied.
The Swiss got one of the breaks back but could not work his usual magic as the contest was squared at a set each.
The victory in just under two hours left Federer with a perfect 6-0 record over Paire, who angrily slashed his racquet across the grass in moments of desperation, drawing jeers from the crowd.
Had he lost on Thursday, Federer would have surrendered the world top ranking to Rafael Nadal at Wimbledon.
However, his escape act against Paire means he has now won 18 straight matches on his favoured grass surface, a run of success dating back a year.
Federer is seeking a 99th career title this weekend and could possibly be playing for his 100th at Wimbledon next month, where he has won eight of his 20 Grand Slam trophies.
Ebden reached the semi-finals in the Netherlands last week, where he lost to Jeremy Chardy.
The Australian needed just over 90 minutes to beat Kohlschreiber, the 2011 title winner in Halle. The Aussie fired seven aces while breaking four times.
Kohlschreiber is usually strong in his homeland where he is 121-64 with five of his eight ATP titles coming in Germany.