Rafael Nadal headed home from the ATP Finals on Friday after defending champion Alexander Zverev's win against Daniil Medvedev confirmed the Spaniard's exit from the season-ending tournament.
The world number one recovered to beat Stefanos Tsitsipas 6-7 (4/7), 6-4, 7-5 in the early round-robin match at London's O2 Arena but knew he was dependent on the later result.
Zverev's 6-4, 7-6 (7/4) win meant he qualified for the semi-finals from Group Andre Agassi alongside Tsitsipas.
Tsitsipas, who topped the group, will play six-time champion Roger Federer in Saturday's semi-finals while Zverev will meet Dominic Thiem, who finished ahead of Federer in Group Bjorn Borg.
German seventh seed Zverev broke the fourth-seeded Medvedev early, with the Russian knowing he was already heading out of the tournament after two defeats.
But Medvedev dug deep in the second set, fending off the single break point engineered by Zverev and took the set to a tie-break but could not keep his big-serving opponent at bay.
Zverev, who beat Novak Djokovic in the final last year, has had a mixed season but now has the chance to end it on a high in London.
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 Zverev in his opening match.
But the 19-time Grand Slam champion produced an astonishing comeback to defeat Medvedev 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 Tsitsipas taking it on a tie-break.
But Nadal put increasing pressure on his opponent's serve and a single break in sets two and three were enough for him to seal the match.
Following his win Nadal was in the strange position of not knowing whether he would qualify for the knockout rounds or not.
He 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."
Federer secured a spot in the semi-finals for the 16th time in his career on Thursday by beating Djokovic in straight sets.