In the final stretch of a match that featured wild swings in momentum, Federer was broken when he served for the match at 5-3 in the fifth set, but he broke Tiafoe in the next game to win.

Federer, who turned 36 this month, won the Australian Open and Wimbledon and has lost only three matches this year.

Entering the match, some mystery surrounded the state of Federer’s back, which hampered him in the final of the Rogers Cup in Montreal and forced him to withdraw from the recent Cincinnati tournament. He was sloppy, committing 56 unforced errors, and struggled on his serve. He said after the match, though, that he felt fine.

The match capped a day on which rain had suspended play on the outside courts around 12:45 p.m. About three hours later, with persistent rain in the forecast, the tournament postponed all but one of the matches on outside courts. That left only matches played under the roof at Ashe Stadium on the schedule.

Federer’s longtime rival Rafael Nadal, the No. 1 seed, also had a few some shaky moments Tuesday but overcame them to defeat Dusan Lajovic of Serbia, 7-6 (6), 6-2, 6-2.