(CNN)World No.1 Rafael Nadal beat Dominic Thiem in a grueling five-set quarterfinal, recovering from a disastrous opening set to clinch the match in dramatic style.
Finishing just after 2 a.m local time, the defending champion saw off his younger Austrian opponent 0-6 6-4 7-5 6-7 (4-7) 7-6 (7-5) in what was his longest match at the US Open.
Top seed Nadal said "suffering" was the "right word" to describe the 4 hour, 48 minute contest.
"It's been a great battle, the conditions were tough, a lot of humidity. It was a very tough start, I tried to stay in the match in the second set," the Spaniard said on court.
"I just (kept) going, I'm very sorry for Dominic, he's a close friend on tour, a great guy, and I wish him all the very best.
"He's young, he has plenty of time to win big tournaments. He's a fighter, he has a great attitude. I'm sure he will have his chances in the future."
The 32-year-old Nadal, a three-time champion at Flushing Meadows, will play third seed Juan Martín del Potro in the semifinals.
Nadal was overpowered by ninth seed Thiem -- the only man to beat him on clay for the last two seasons -- in the first set as the 25-year-old hit 13 winners and made only two unforced errors in an extraordinary start.
But the 17-time grand slam champion battled back to win the second and third sets before Thiem came out on top of an 81-minute fourth set to take the match into a nerve-wracking decider.
At 5-5 and 0-40, Thiem saved all three break points and forced the fifth set into a tiebreak, but it was Nadal who came out on top when the Austrian sent a smash long.
It meant the Spaniard avoided following world No.2 Roger Federer, who surprisingly lost to world No.55 John Millman Monday, out of the competition.
"This match is going to be stuck in my mind forever -- tennis is cruel sometimes," Thiem, comprehensively beaten by Nadal in June's French Open final, told reporters.
"This match didn't deserve a loser, but there has to be one."