Novak Djokovic was again made to fight hard as he beat American wildcard Jenson Brooksby to reach the US Open quarter-finals and keep his calendar Grand Slam hopes alive.
The world number one overcame a poor first set to win a bruising encounter 1-6 6-3 6-2 6-2.
He was pushed all the way by Brooksby, who was well-supported by the full crowd on Arthur Ashe Stadium.
Djokovic will face Matteo Berrettini for a place in the semi-finals.
Djokovic is three wins away from his 21st Grand Slam title, which would be a men's record.
He found himself embroiled in a superb encounter with world number 99 Brooksby, with momentum switching back and forth across the two hours 58 minutes.
The two players found themselves involved in punishing rallies, with the crowd often out of their seats to applaud their court coverage and shots.
They shared a warm handshake at the net, with Djokovic offering some words of encouragement to the 20-year-old.
"He just played a perfect first set and he is very clever. I couldn't do anything," Djokovic said.
"I enjoyed it, I truly did. You [the crowd] gave both players amazing energy to show what we can do."
Brooksby may rue the chances he let slip - he converted just three of 11 break points - but it is testament to Djokovic's fitness and stamina that he was able to keep in front in almost every set.
Djokovic, who beat Italy's Berrettini in the Wimbledon final last month, has yet to produce a completely clinical performance in New York.
He has dropped a set in all but one of his matches and once again started slowly, hitting 11 unforced errors to just one from Brooksby in the opener.
Brooksby matched Djokovic run for run for much of the match, keeping with him in lengthy rallies and making his opponent look uncomfortable.
A 20-minute game on the Djokovic served highlighted the competitiveness - it contained 24 points, nine deuces, and six break points, with Brooksby eventually converting on a backhand error from the Serb.
While Brooksby did his best, he simply ran out of energy quicker than Djokovic, who is the best athlete on the men's tour.
He lost the break of serve almost straight away and Djokovic closed out the set, with both players taking medication in the break.
Brooksby also received treatment to his thigh and was breathing heavily between points as he tried to keep up with Djokovic, who finally seemed to adjust to his game in the last two sets.
Djokovic finished the match with 41 unforced errors - something he knows he will need to cut out before facing Berrettini.
The sixth seed earlier defeated German qualifier Oscar Otte 6-4 3-6 6-3 6-2.
Berrettini, who reached the US Open semi-finals in 2019, was comfortable throughout despite dropping serve onnce in the third set.
He is joined in the quarter-finals by fourth seed Alexander Zverev, who beat Jannik Sinner.
The German, who lost to Dominic Thiem in last year's final, beat Italy's Sinner 6-4 6-4 7-6 (9-7).
He will face Lloyd Harris for a semi-final spot after the South African beat Reilly Opelka in four sets.
Zverev is on a 15-match winning streak, having claimed the Cincinnati Open title in the lead-up to the US Open and Olympic gold in Tokyo.
-BBC