Novak Djokovic beat Joao Sousa 6-3 6-4 6-3 to reach the US Open quarter-finals, where he could meet long-time rival Roger Federer.
Two-time champion Djokovic broke twice in the first set but had to recover from a break down in the second.
The Serb, 31, struggled physically in the third set and went off court for a medical time-out when he led 2-1.
But he got the crucial break to take a 5-3 lead before serving out the match to secure his place in the last eight.
The Wimbledon champion has never lost a set against the Portuguese world number 68, who had reached the fourth round of a Grand Slam for the first time.