It was a much tougher test than might have been expected, considering that Federer entered the match 16-0 against Youzhny and 16-0 in second-round matches at Flushing Meadows.
Federer won five consecutive U.S. Open championships from 2004-08 and also was the runner-up twice, including two years ago.
Youzhny is a former top-10 player who reached the U.S. Open semifinals in 2006 and 2010. His level of play dipped considerably over the last two sets Thursday as he appeared to be restricted by a leg cramp.
The 36-year-old Federer was not quite himself for much of the match, either. He committed 68 unforced errors and appearing slowed by a bad back that he tweaked earlier in August.
Federer also needed five sets to win in the first round Monday night against 19-year-old American Frances Tiafoe.
The 53rd-ranked Rublev eliminated No. 7 Dimitrov 7-5, 7-6 (3), 6-3 to reach the third round at a major tournament for the first time.
Dimitrov is a three-time Grand Slam semifinalist who had been playing well leading into Flushing Meadows. He had won 13 consecutive sets heading into Thursday, dating to the Cincinnati Masters, where he won his first title at the tour tier just below the majors.
Against Rublev, Dimitrov double-faulted 11 times and converted only 2 of 10 break points.
Dimitrov’s exit raises to six the number of members of the ATP’s top 10 who are out of the field in New York. No. 2 Andy Murray, No. 4 Stan Wawrinka, No. 5 Novak Djokovic and No. 10 Kei Nishikori all sat out the US Open with injuries, and No. 6 Alexander Zverev lost to 18-year-old Canadian Denis Shapovalov in the second round Wednesday night.
In another early match Thursday, Alexandr Dolgopolov, who was involved in a match at another tournament that’s under scrutiny because of unusual betting patterns, eliminated No. 15 seed Tomas Berdych to reach the Open’s third round.
Dolgopolov beat 2010 Wimbledon runner-up Berdych 3-6, 6-1, 7-6 (5), 6-2.
Tennis Integrity Unit spokesman Mark Harrison said the group “was made aware of concerns over betting patterns” during the match between Dolgopolov and Thiago Monteiro at Winston-Salem, North Carolina, on Aug. 20. The match is being assessed but is not yet under formal investigation, Harrison said.
Harrison notes that many reasons other than corruption can explain unusual betting patterns.
The Associated Press contributed to this report.