Novak Djokovic beat Joao Sousa 6-3 6-4 6-3 to reach the US Open quarter-finals, where he will meet Roger Federer’s conqueror John Millman.
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 timeout 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 world number 55 John Millman after the Australian shocked 20-time Grand Slam champion Federer.
ALSO READ: Federer suffers shock US Open defeat
The Swiss lost to a player ranked outside of the top 50 for the first time at the US Open as Millman, 29, triumphed 3-6 7-5 7-6 (9-7) 7-6 (7-3).
Despite winning in straight sets, it was not a comfortable afternoon for Djokovic.
He appeared to struggle with the humidity at the end of the second set and asked for towels of ice to be placed around his neck and on top of his head during the changeovers.
The Serb had similar issues in his first-round match with Marton Fucsovics – he was unsteady on his feet and asked for a sick bucket to be put next to his chair.
Djokovic was breathing heavily in the third set and signalled to the medical team before receiving treatment off court.
“I prefer not to talk about how difficult it was,” said Djokovic. “We are blessed to play this sport and this is one of the biggest stages.
“I’m not 21 anymore. I still don’t feel old but at the same time there is a biological clock that doesn’t work in your favour like it does when you’re 20.
“You have a team to get you ready, but sometimes you just have to survive.”
Meanwhile, 2014 finalist Kei Nishikori reached the last eight after beating Philipp Kohlschreiber 6-3 6-2 7-5.
The world number 19 will face Croatian seventh seed Marin Cilic after he recovered from a break down in the first set to beat David Goffin 7-6 (8-6) 6-2 6-4.
It will be a re-match of their final from four years ago, which Cilic won 6-3 6-3 6-3 to become the first Croat to win one of the four tennis majors since his coach, Goran Ivanisevic, at Wimbledon in 2001.
Cilic later said Goffin had told him he had been struggling with a shoulder issue.
“After the first set it felt like he slowed down his first serve and at the end he told he’s got some problems with his shoulder so it was a little but unfortunate for him and he was not playing the best the last two sets but I kept my rhythm and played well,” Cilic said.