The decision was the latest setback for the 23rd-seeded Fish, who missed part of the season because of a heart ailment and had treatment for an unspecified illness after his gruelling third-round win over Gilles Simon late on Saturday.
"I regret that I have to withdraw from the US Open for precautionary measures," American Fish, who was set to clash with Federer on the Arthur Ashe Stadium centre court on Monday afternoon, said in a statement.
"I was reluctant to do so, but am following medical advisement. I had a good summer and look forward to resuming my tournament schedule in the fall."
The decision means Federer, who has not dropped a set in this year's US Open at Flushing Meadows, advances to his 34th consecutive Grand Slam quarter-final.
The 31-year-old Swiss will now play Tomas Berdych after the Czech sixth seed thrashed Spain's Nicolas Almagro 7-6 6-4 6-1.
"I am really sorry for Mardy. I just want to wish him a speedy recovery. We all want to see him back on tour soon," said Federer, who owns an 11-4 career record against Berdych.
"It will be a tough match against Tomas. We have played many times in the past and he has always been a tough opponent. I will have to continue to serve well and dictate the points."
- Sports & Recreation
- Tomas Berdych