When announcing he would not play in the 2023 French Open, Nadal said he planned to retire at the end of 2024 because of the series of injuries which were taking their toll on his body.
But, having returned earlier this season, Nadal became increasingly non-committal about his future.
The former world number one regularly said he wanted to keep playing as long as his body let him.
Now, after a chastening defeat by long-time rival Djokovic at the Paris Olympics in July, he has decided the time is right.
“It is obviously a difficult decision, one that has taken me some time to make,” he said.
“But, in this life, everything has a beginning and an end.”
After returning to competitive action in Brisbane in January, Nadal was sidelined again with a thigh injury, missing the Australian Open.
Nadal played four tournaments during the European clay-court season, culminating in a first-round defeat at the French Open.
Since then he has played just two more tournaments – in Bastad and the Olympic Games at Roland Garros.
Last month he was included in Spain’s squad for the Davis Cup Finals, which takes place between 19-24 November.
“I think it’s the appropriate time to put an end to a career that has been long and much more successful than I could ever have imagined,” Nadal said.
“I’m very excited that my last tournament will be the final of the Davis Cup and representing my country.”
He has not played competitively since teaming up with Carlos Alcaraz – long seen as Nadal’s heir at the pinnacle of Spanish men’s tennis – in Olympics doubles earlier this year.
Alcaraz said being given the opportunity to play with his idol was an “immense gift” and the news of his retirement was “tough to accept”.
“I was in shock a little bit,” added Alcaraz, who heard the news shortly before he lost in the Shanghai Masters quarter-finals.
“Losing him, in a certain way, is going to be difficult for us, so I will try to enjoy as much as I can when he’s going to play.”