Basel - Roger Federer struggled into the Swiss Indoors semi-finals on Friday, the top seed eking out an error-filled 7-6 (7/1), 4-6, 6-4 defeat of Gilles Simon.
Federer has not hit top form all week in Basel and he needed more than two-and-a-half hours to hold off the troublesome French veteran.
The Swiss crowd favourite was never able to comfortably take command against an opponent whom he had defeated in their last six meetings.
It took a fightback in all three sets to come through for a place in a 14th semi-final at the event where he got his start in the game as a ballboy.
The 20-time Grand Slam champion will have to re-group quickly for the semis, where he will play the winner from Greek breakthrough player Stefanos Tsitsipas and Daniil Medvedev.
Both young guns have won tournament titles this autumn.
In the quarters, Federer found himself in 2-5 trouble after another sluggish start, with Simon quickly finding his range against the number three.
The Swiss had his chances to recover in the seventh game, but two break-back chances went for nought.
Federer started his slow recovery with a break for 4-5; he then saved set points to level at 6-all, winning a game in which he double-faulted twice in a row and saved a set point with an ace.
Federer came alive in the tiebreaker, racing to a 5-1 lead and earning the set after an hour of hard graft on a Simon backhand error.
Just as Federer looked to be settling into form after nearly 30 unforced errors in the opening set, more disruption ensued.
The 32nd-ranked Simon continued to make the match a struggle, with the pair trading four breaks in a row until Federer took a 4-3 lead.
But the margin lasted for only two games as the Swiss dropped serve for the fourth time to trail 4-5 as Simon struck a down-the-line winner.
The Frenchman levelled the sets at one apiece a game later.
The third set looked like going Federer's way, with the seed breaking in the second game, but losing serve in the seventh.
Simon found level-pegging for 4-all. But a quick match point opportunity two games later allowed Federer to close as his opponent sent a return over the baseline.
This was Federer's 18th consecutive winning match at a tournament where he is unbeaten since 2013 and is an eight time winner.
Earlier, second seed Alexander Zverev hammered a dozen aces to reach the final four with a 7-5, 6-3 defeat of Roberto Bautista Agut.
The win was a reversal of the first main draw match of Zverev's career when, as a 16-year-old wild card, he lost to Bautista Agut in Hamburg in 2013.
The 21-year-old German rallied from a break down in the second set to overhaul the Spaniard in one and three-quarter hours.
"He's a tough player with a dangerous game," the winner said as he prepared to face Romanian qualifier Marius Copil, who defeated Taylor Fritz 7-6 (8/6), 7-5.
Zverev needed an hour to claim the opening set against Bautista Agut, reaching set point in the first with a backwards between-the-legs 'tweener' which landed good.
In the second, he trailed, but was able to recover and complete victory, his 52nd of the season.
"(Trailing) 3-0 in the second, I started to play more aggressive. I was able to play my game," Zverev said.
"Copil has nothing to lose coming from qualifying, so I have to be ready for anything."
Zverev owns three titles this season, form Munich, Madrid and Washington.