Roger Federer had to fight hard to hold off Serbia's Filip Krajinovic on Tuesday, edging to a 6-2 4-6 6-4 win to reach the second round of the Swiss Indoors.
The eight-time champion flirted with his earliest exit in Basel since his 1998 debut as a teenager, but came out on top in a nervy deciding set.
"I was up 6-2, 3-1, it could have ended very quickly," Federer said. "But I made life more difficult. I didn't have the best serving stats, maybe that caught up to me. But these are different balls, more altitude than in Shanghai, it's about getting used to it.
"And first rounds are always tricky, it's never a given that you are going to win."
Earlier, Jan-Lennard Struff ended the possibility of a rematch between Federer and his US Open conqueror John Millman by beating the Australian 7-6 (7/3), 6-2.
Krajinovic appeared to be on the way to a straight-sets loss in his first meeting with the 20-time Grand Slam winner before the momentum began to turn.
Up a set and a break, the Swiss lost serve in the sixth game of the second set before his opponent managed to square the match with a break in game 10.
The top seed went up an early break in the third and broke Krajinovic in an 11-minute game for a 5-2 lead, only to fail to serve out the match at the first time of asking.
But he clinched victory on his second match point to take his career record at the tournament to 67-9 as he bids to reach a 12th successive final at St. Jakobshalle.
"I'm glad I got through. These are the matches you have to win," said Federer. "Things didn't really flow, but it was a hard-fought win. I feel good physically. I have a day off tomorrow so it was no trouble to play three sets. I'm happy where I am right now."
The 37-year-old Federer, who revealed earlier this week that he had been struggling with a hand injury since the grass-court season, last lost at the Swiss Indoors in 2013, going down to Juan Martin del Potro.
Seventh seed Daniil Medvedev, a semi-finalist last week in Moscow, saw off German Maximilian Marterer 6-3, 7-5.
Russian Medvedev stands at a career-high ranking of 20th, with three titles this season and will next face Andreas Seppi after the Italian defeated Japan's Taro Daniel 6-0, 6-4.