Rafael Nadal
Rafael Nadal celebrates after winning the third set during the men's singles quarter-final match against Dominic Thiem on Day Nine of the 2018 US Open at the USTA Billie Jean King National Tennis Center in the Flushing neighborhood of the Queens borough of New York City, Sept. 4, 2018. Matthew Stockman/Getty Images

World No. 1 Rafael Nadal had to endure a near-five hour war with Dominic Thiem to reach the semifinals of the US Open as he eventually won the contest 0-6, 6-4, 7-5, 6-7, 7-6 (5) on Tuesday night.

Before the quarterfinal clash, Nadal led their head-to-head meetings 7-3; however, all their meetings had come on clay, making this encounter a particularly intriguing one.

However, nobody expected Thiem to bagel Nadal as he took the first set 6-0, with the latter winning just seven points in the six games. It also marked just the third time the Spaniard had been bageled this decade as well as the third in Grand Slam competitions before, all three notably resulting in losses.

That wasn't to be the case this time as Nadal bounced back in the second set, breaking the 25-year-old twice to eventually serve for the set.

Nadal would win the third set as well, but the tie still remained extremely competitive throughout, with Thiem's backhand winners becoming a theme of the contest.

However, it was Thiem who needed to bounce back this time as he took a 4-2 lead in the fourth set. Nadal, though, really started to hit top gear as he broke Thiem back to take a 5-4 lead.

The Austrian tied it up at 5-5 and had break point only for Nadal to rally and take a 6-5 lead.

Despite having a chance to earn match point at 30-30, Nadal made two unforced errors at the net to allow Thiem to take the fourth set to a tie-break. The unforced errors continued for the 31-year-old as Thiem took the match to five sets after winning the tie-break 7-4.

The fifth and final set remained as close as ever, though Thiem saved a remarkable three break points to take a 6-5 lead before the contest entered a decisive tie-break.

It was a nerve-wracking tie-break poised at 5-5 but it was Nadal who eventually came through to win the final set.

"It's been a great battle. The conditions were tough. It was a very tough start," Nadal said after the match. "I tried to stay in the match in some way. I just keep going. Being honest, I'm very, very sorry for Dominic. He's a fighter. He has a great attitude. A top person. I'm sorry for him but I'm sure he will have his chances in the future without a doubt."

Nadal will now face Juan Martin del Potro in the semifinals after the latter defeated American John Isner 6-7, 6-3, 7-6, 6-2 earlier in the day.

Del Potro notably won the US Open in 2009, his only major, and will provide an extremely tough task for Nadal. The Argentine currently trails him in their head-to-head meetings 17-5, but interestingly, all five of his wins over the 17-time Grand Slam champion have come on the hard-court surface.

Meanwhile, Wimbledon champion Novak Djokovic takes on John Millman while Kei Nishikori faces Marin Cilic on Wednesday to determine the other semifinal participants.