Rafael Nadal survived a four-hour examination by Karen Khachanov to keep the defence of his US Open title just about on track.
The world number one, who had his right knee strapped at the end of the first set, looked in serious trouble when Russian Khachanov served for a two-set lead in the third-round clash.
But Nadal proved just good enough when it counted and clinched a 5-7 7-5 7-6 (9/7) 7-6 (7/3) victory after four hours and 23 minutes.
The good news for Nadal, who next meets Georgia’s Nikoloz Basilashvili, is he survived on a day when he struggled to find his rhythm and clearly was not feeling physically at his best.
Khachanov, meanwhile, showed that at 22 he possesses all the ingredients to be going a lot further at grand slams very soon, although double faults hurt his cause, especially in the third-set tie-break.
Nadal said: “It has been a tough situation, a great opponent. I’m very happy to be through. Probably there’s things to work on for the next match but the victory means I have the chance to do it.”
Khachanov, who had never previously taken a set off Nadal, is one of the new-generation powerhouses – 6ft 6in, athletic, dynamic and with the strength and aggression to bully players off the court.
Nadal is normally the one doing the bullying but this was a match he found unable to play on his own terms for more than a few points at a time.
The Spaniard recovered an early break, becoming the first player to break the Khachanov serve this tournament, only to drop serve again at 5-5.
He made Khachanov fight all the way to serve out the opening set in a game full of drama but could not repair the damage.
Nadal is no stranger to slow starts but the sense this may be more serious grew. As well as the strapping on his knee, there were anxious glances to his box, and soon he was a break down again.
The crowd were fully behind the Spaniard and roared as he pulled back to 4-4 only to drop serve again when a routine forehand sailed wide, Nadal hanging his head in frustration.
That gave Khachanov, ranked 26, the chance to serve out the second set but he could not take it and, as Nadal broke back, rain began to fall, prompting the second delay of the day for the roof to be closed.
Indoor conditions could have been expected to favour Khachanov but the break gave Nadal time to refocus and he moved closer to the baseline, finally exerting some control and being rewarded with the set.
The leaping, fist-pumping celebration showed how important a moment it was, but still he could not shake off Khachanov, who held firm to force a third-set tie-break.
And what a tie-break. It rather summed up the match, with sublime play from both men but also baffling errors. Khachanov served three double faults while Nadal let a 6-3 lead slip away before being rewarded for bravery in a 39-shot final rally.
Two more double faults cost Khachanov an early break in the fourth set and for the first time the Russian’s head dropped a little. He raised it again to put the pressure back on and bit back when Nadal served for the match at 5-4, breaking to love.
Khachanov had one set point at 5-6 but netted a backhand and that proved to be his final chance as Nadal dominated the tie-break.