The third-seeded Federer was pushed to five sets for the second consecutive match before outlasting Russian Mikhail Youzhny 6-1, 6-7 (3), 4-6, 6-4, 6-2 on Thursday to advance to the third round of the U.S. Open.
Being tested by players like Frances Tiafoe and Youzhny in the first two rounds wasn't part of the forecast for a legend shooting for his sixth U.S. Open crown. Going five sets certainly wasn't part of the equation.
"These five-set battles are actually quite a lot of fun," Federer said in a post-match interview.
Federer improved to 17-0 all-time against Youzhny, who played a spirited match before Federer won the last two sets.
"We've played a bunch of times and this was probably our best match," the Swiss star said. "It was fun playing out here today."
Victory No. 80 was aided by the 101st-ranked Youzhny developing leg cramps and he was visibly affected in the final set.
Federer had 63 winners and 12 aces while overcoming a staggering 68 unforced errors. Youzhny nailed 27 winners but sabotaged himself with eight double faults and 55 unforced errors.
Seventh-seeded Grigor Dimitrov of Bulgaria was sent packing as Russian Andrey Rublev fired 36 winners while registering a 7-5, 7-6 (3), 6-3 upset.
"I think my style of game is to just play aggressive, to try to play with my rhythm because I have quite good rhythm," the 19-year-old Rublev said afterward. "I can compete with many good guys. I think this is one of the main things of my game.
"Of course, to try to work hard, to try to improve all the things that I need to improve every day. I hope that I'm doing better and better. In this way, I have better results and ranking."
Rublev next faces Bosnian Damir Dzumhur, who defeated Germany's Cedrik-Marcel Stebe 4-6, 6-4, 6-0, 6-1.
Also upset was 15th-seeded Tomas Berdych of the Czech Republic. Alexandr Dolgopolov of the Ukraine recovered from losing the first set to deliver a 3-6, 6-1, 7-6 (5) 6-2 victory.
Sixth-seeded Austrian Dominic Thiem beat American Taylor Fritz 6-4, 6-4, 4-6, 7-5, ninth-seeded Belgium David Goffin outlasted Argentina's Guido Pella 3-6, 7-6 (5), 6-7 (2), 7-6 (4), 6-3, and No. 11 seed Roberto Bautista Agut of Spain notched a 6-1, 6-3, 7-6 (3) victory over Germany's Dustin Brown.
Argentina's Juan Martin del Potro had few issues while sailing to a 6-2, 6-3, 7-6 (3) win over Spanish qualifier Adrian Menendez-Maceiras. The No. 24 seeded had 40 winners, including 17 aces.