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.
Djokovic has reached the semi-finals of the US Open in every year he has competed since 2006.
He will face Federer next if the Swiss 20-time Grand Slam champion beats Australian John Millman later.
The former world number ones have not faced each other this early in a Grand Slam since the 2007 Australian Open, when Federer won to reach the last eight.
Millman, the world number 52, knocked out 14th seed Fabio Fognini in the second round.