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 Daniil Medvedev.
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.
While, Marius Copil on Saturday became the first qualifier to reach the final of the Swiss Indoors in more than a decade as the Romanian upset Alexander Zverev 6-3, 6-7 (6/8), 6-4.