Rafael Nadal ultimately had too much quality for Marin Cilic in a 6-3 3-6 6-1 6-2 victory in New York to reach the US Open quarter-finals.
"For some moments in the second set I felt there were too many points in his hands, he was pushing me back, more aggression than me and he hit every ball very strong," said Nadal.
"After that second set I thought something needs to change or I would be in his hands. I started to return the second serve inside the court and that created a different perspective."
Federer, 38, plays his quarter-final against Bulgaria's Grigor Dimitrov at about 02:00 BST on Wednesday.