The world number three hit 17 unforced errors in losing the first set as he (Roger Federer) came from a set down to beat Damir Dzumhur 3-6 6-2 6-3 6-4 under the Arthur Ashe Stadium roof to reach the US Open third round.
But the Swiss five-time champion dominated the remainder of the match to defeat Bosnian world number 99 Dzumhur.
Victory for the 38-year-old sets up a third-round match against either Britain’s Dan Evans or Frenchman Lucas Pouille at Flushing Meadows.
Evans and Pouille will play on Thursday after rain in New York forced the cancellation of Wednesday’s day session on the outside courts.
Federer dropped the opening set in his first-round win over Indian qualifier Sumit Nagal and he made another slow start here, losing the first four games of the match.
“I don’t think there is a secret to a good start other than warming up well, being well prepared mentally and not underestimating your opponent. I did all of that,” said Federer, after a match played under the roof because of rain in New York on Wednesday.
“So when it happens in back-to-back matches it’s a bit frustrating more than anything, especially when the level is that low and there are that many errors and the energy is not kind of there.
“But I’m not concerned because once I lose that first set I do get better, which is a good thing.”
After serving out the first set, 27-year-old Dzumhur held a breakpoint in the opening game of the second set but could not convert.
Federer then immediately broke with a forehand winner and levelled the match through another break when Dzumhur double-faulted.
The Swiss broke at the first opportunity in the second set but had to save four break points in the seventh game as Dzumhur continued to push him.
After sealing the set with an ace, a forehand winner allowed Federer to break in the third game of the fourth set and he went on to seal victory in two hours and 22 minutes.
Federer hit 16 aces to Dzumhur’s two and 58 winners overall – more than double his opponent’s 26.