Novak Djokovic avoided a huge shock as he recovered from a two-set deficit to beat fellow Serb Laslo Djere and reach the US Open fourth round.
Djokovic, 36, maintained his bid for a record-equalling 24th major title with a 4-6 4-6 6-1 6-1 6-3 win in New York.
It is the eighth time in Djokovic’s career he has fought back from two sets down to win.
On how a break after the second set helped his comeback, he said: “I did a pep talk in the mirror. It worked.”
He added: “I laughed at myself because I was so agitated and annoyed with the game. I had to force myself to lift my spirits.”
Three-time US Open champion Djokovic, who is aiming to move level with Australian Margaret Court’s tally of major wins, will play Croatian qualifier Borna Gojo in the last 16.
Gojo, ranked 105th in the world, continued his remarkable run at Flushing Meadows with a 6-4 6-3 6-2 win over Czech Jiri Vesely.
How Djokovic came through ‘one of toughest US Open matches’
Djokovic will be the overwhelming favourite to beat 25-year-old Gojo when they meet on Sunday, but showed he can still be vulnerable with a poor start against 32nd seed Djere.
However, he also showed all of the tenacity and powers of recovery which have made him arguably the greatest player of all-time.
Seeded second behind Spanish youngster Carlos Alcaraz in New York, Djokovic was considered as the joint favourite for the title even before his half of the draw further opened up after a number of top seeds were knocked out.
Djere has played some of the best tennis of his career this year, but few would have predicted he would threaten an upset against his compatriot.
He made the perfect start by breaking Djokovic’s serve in the first game of the match and continued to take advantage of his opponent looking off the pace.
Using the drop shot to good effect, Djere maintained his lead in the opening set and a single break in the second made the implausible look more possible.
Against someone of Djokovic’s calibre, there was still a long way to go, however.
The contest pivoted when Djokovic broke his opponent’s serve at the start of the third set, hanging on in a 26-shot rally on break point and gaining the advantage when Djere hit a return into the net.
Djokovic, who will return to the top of the world rankings after the US Open whatever happens, raced through the set and further upped the intensity in the fourth.
The set started with three successive breaks of serve before Djokovic, putting his opponent under severe pressure by returning balls few others could, rattled off the next four games against a wearier-looking Djere.
When Djokovic moved 3-0 in front in the decider, it looked like the match would quickly be over.
Djere, though, refused to be steamrollered. Djokovic had to save a break point at 5-3, then hit a match point into the net after a tense baseline exchange, before taking his second chance to clinch victory at 01:32 local time.
After clapping Djere out of Arthur Ashe Stadium, Djokovic said: “It was one of the toughest matches I’ve played here in many years.
“Huge, huge credit to Laslo for playing some of the best tennis I’ve ever seen him play.”
‘Stoked’ home crowds celebrate wins for US men
Elsewhere, American quartet Taylor Fritz, Frances Tiafoe, Tommy Paul and Ben Shelton kept alive the nation’s hopes of a first home men’s singles champion since Andy Roddick in 2003.
Tiafoe, seeded 10th, is into the fourth round for the fourth successive year after overcoming a slow start to beat France’s Adrian Mannarino 4-6 6-2 6-3 7-6 (8-6).
American men’s number one Fritz, 25, needed only an hour and 30 minutes to win 6-1 6-2 6-0 against Jakub Mensik – on the Czech teenager’s 18th birthday – to record his best run.
Paul, who won 6-1 6-0 3-6 6-3 against Spain’s Alejandro Davidovich Fokina, will play compatriot Shelton in the last 16 after he beat Russian Aslan Karatsev 6-4 3-6 6-2 6-0.
Rising star Shelton hit 26 aces, including one 147mph serve – the fastest of the tournament so far.
“This is the best tournament for Americans to play in,” said 26-year-old Paul, who reached the last 16 for the first time.
“Obviously around the grounds everyone is really stoked and excited about the Americans.
“Every time I pass one of the TVs here it’s like ‘is an American gonna win a (singles) slam for the first time in 20 years?'”
Last year Tiafoe achieved his best Grand Slam result to date when he reached the last four, where he lost to Alcaraz in five sets.
The 25-year-old said he is motivated by Arthur Ashe, the 1968 champion who Flushing Meadows’ main court is named after.
Ashe remains the only black man to win the US Open, Australia Open or Wimbledon singles titles.
“I have always watched this tournament as a kid and wanted to play out here and in the biggest stages,” Tiafoe said.
“There is so much history here. Obviously, Arthur Ashe – what a legend. I just want my name in the same sentence as his. That is why I play my best tennis here.”