London - Rafael Nadal recovered to beat Stefanos Tsitsipas 6-7 (4/7), 6-4, 7-5 on Friday, but faces an anxious wait to find out whether he will play Roger Federer in the last four at the ATP Finals.
The Spanish top seed is pinning his hopes on Daniil Medvedev beating defending champion Alexander Zverev in the evening match in Group Andre Agassi in London.
Nadal's efforts will count for nothing unless Medvedev, who now has nothing to play for, beats Zverev. A win for the German would send Nadal home.
"I don't know if I will see you tomorrow because it depends on the match of this evening, but I did all the things that I could today," said Nadal.
"I fought until the end two days ago and today, so if I am able to play in front of you tomorrow against Roger it will be a huge honour. If not, I really hope to see you next year."
Nadal, who has already secured the year-end number one ranking, has never won the end-of-season tournament and had a miserable start at the O2 Arena, being outplayed by Germany's Zverev.
But the 19-time Grand Slam champion produced an astonishing comeback to defeat Medvedev, the Russian fourth seed, on Wednesday and give himself a chance of qualifying from the round-robin phase.
Tsitsipas, 21, had already qualified for the semi-finals before Friday's match after beating Medvedev and Zverev.
Serve dominated in the first set on Friday, with neither Nadal nor Tsitsipas facing a break point as the match drifted inexorably towards a tie-break.
The Greek sixth seed came out on top, hammering an ace on his first match point to seal the set.
The second set followed a similar pattern until the fifth game, when a Tsitsipas double-fault handed Nadal two break points - the first of the match.
The Spaniard could not capitalise but he upped the pressure in Tsitsipas's next service game and earned another break point, which the Greek again survived.
But Nadal earned a fourth break point in Tsitsipas's next service game and this time the Greek player slapped a regulation forehand wide and Nadal went on to level the match.
A pumped-up Nadal maintained his momentum in the early stages of the deciding set, putting consistent pressure on his opponent's serve but he failed to convert a clutch of break points.
Nadal earned two more break points in the 11th game and this time made it count as Tsitsipas put a backhand wide and he served out to win the match.
After the match Nadal received the trophy for finishing the year as the top-ranked player.
"I'm super happy," he said.
"Honestly, after all the things I went through in my career in terms of injuries I never thought at the age of 33-and-a-half I would have this trophy in my hands again.
"It's something really, really emotional for me. A lot of work in the shadows to be where we are today."
Six-time champion Federer, who was in Group Bjorn Borg, secured a spot in the semi-finals for the 16th time in his career on Thursday by beating Novak Djokovic in straight sets.
Austrian fifth seed Dominic Thiem also qualified for Saturday's semi-finals.
Results on the sixth day of the ATP Finals at London's O2 Arena on Thursday (x denotes seeding):
Group Andre Agassi
Rafael Nadal (ESP x1) bt Stefanos Tsitsipas (GRE x6) 6-7 (4/7), 6-4, 7-5
Daniil Medvedev (RUS x4) v Alexander Zverev (GER x7)
Group Max Mirnyi
Juan Sebastian Cabal/Robert Farah (COL/COL x1) bt Kevin Krawietz/Andreas Mies (GER/GER x3) 7-6 (9/7), 6-2
Jean-Julien Rojer/Horia Tecau (NED/ROU x6) v Pierre-Hugues Herbert/Nicolas Mahut (FRA/FRA x7)