Rafael Nadal talks with a trainer shortly before retiring before the third set of his U.S. Open semifinal against Juan Martin del Potro. (JASON SZENES/EPA-EFE/REX/Shutterstock)

Rafael Nadal spent 17 hours 55 minutes pounding his 32-year-old knees on hard courts and supplied two marathon blocks of entertainment before he ripped off his headband Friday and signaled to the chair umpire that he was done. His body had given out.

Nadal, the world’s No. 1 player and the defending champion in New York, retired against Juan Martin del Potro, trailing 7-6 (7-3), 6-2, about two hours into the first semifinal of the day in Flushing Meadows. His retirement puts No. 3 seed del Potro back into the U.S. Open final for the first time since the Argentine beat Roger Federer to win the title, his only career Grand Slam championship, in 2009.

The second semifinal provided fewer surprises as No. 6 seed Novak Djokovic advanced, 6-3, 6-4, 6-2, past 2014 finalist Kei Nishikori to meet del Potro in the final. Djokovic will be seeking his 14th major title.

Djokovic had little trouble against Nishikori. His returns again were his strength, but his serve shined; Djokovic lost only 10 points on his first serve, and Nishikori was only able to create two break points. Djokovic saved both.

The 31-year-old will need that serve and superb defense Sunday against del Potro, who is Djokovic’s first big-serving opponent this tournament. The reigning Wimbledon champion owns a 14-4 record against the Argentine, but the two have never met in a Grand Slam final.

Both of their returns to the U.S. Open’s biggest stage represent triumph over injury — Djokovic only returned to the top of the sport this summer in England after a pesky elbow injury, and Del Potro, 29, had so much trouble with injuries to both wrists that he nearly quit the sport in 2015.

Even so, the tone of the first cool, cloudy day at Billie Jean King National Tennis Center was a bit more subdued because of Nadal’s retirement.

“Of course, it’s not the best way to win a match,” Del Potro said. “I love to play against Rafa because he’s the biggest fighter in the sport. I don’t like to see him suffering on court today.”

The first signs of trouble with Nadal’s knee came after the seventh game of the first set, when the Spaniard called the trainer to have his right knee taped just below the kneecap — the same place he had it taped throughout his third-round match against Karen Khachanov, a four-setter that lasted 4 hours 23 minutes.

Nadal, either unhappy or uncomfortable with the trainer’s first tape job — he notoriously dislikes playing with tape on — tore the wrapping off not long after. But he was walking with a hitch in his step and had the trainer out to retape the knee early in the second set. Even after that, Nadal wasn’t able to run like usual.

“It is not about losing,” Nadal said. “It is that I didn’t have the chance to fight for it.”

Friday is the second time this year Nadal retired during a Grand Slam match; he also retired in the fifth set of a quarterfinal match against Marin Cilic at the Australian Open, the sport’s other hard-court major.

The 32-year-old has long suffered from tendinitis in his knees, presumably brought about by his intense style of play. His mobility is perhaps his greatest asset, especially his ability to change direction during the course of a point. It makes him prone to long matches, and his quarterfinal against Dominic Thiem (nearly five hours) was the longest match of the tournament. His match against Khachanov was the second longest.

Nadal indicated that this knee problem is a flare-up of his existing issue, even though it had not been bothering him before Friday’s match.

“I know what is going on with the knee. But the good thing is I know how I have to work to be better as soon as possible because we have a lot of experience on that,” Nadal said.

“The problem is this time it was something a little bit more aggressive because it was in one movement. It was not something progressive. . . . It’s much worse when the thing happens like this, immediately in a bad movement.”

The reigning French Open champion ends his Grand Slam season having made it at least to the quarterfinals in all four majors. In a post-match news conference Friday, he was as frustrated as he was glum to have lost the chance to play for his 18th career major title.

“That’s frustrating. Can’t tell you another thing. Is tough for me,” Nadal said. “. . . I know the things are going the right way. I am playing well. I am enjoying being on court. I am having a lot of success. . . . Lot of people in this room, including myself, would never have thought that at the age of 32 I will be here fighting for titles, fighting for the first positions of the rankings.

“All my career everybody say that because of my style, I will have a short career. I’m still here. I’m still here because I love what I am doing. I still have the passion for the game. I going to keep fighting and working hard to keep enjoying this tour and keep having chances to compete at the highest level. So that’s all.”