Dominic Thiem stunned Novak Djokovic to reach the last four of the ATP Finals and set up a straight shoot-out between the Serbian and Roger Federer to see who joins him.
Federer beat Italian eighth seed Matteo Berrettini 7-6 (2) 6-3 to keep his hopes of reaching the semi-finals alive.
And Thiem won a late-night classic against Djokovic to book his place among the last four for the first time in his career.
It means only the winner of Thursday's match between Djokovic and Federer, who have 11 ATP Finals titles between them, will still be in London over the weekend.
Austrian Thiem, ranked fifth in the world, lost the first set on a tie-break but conjured up arguably some of the finest tennis of his career to level the match and go a break up in the decider.
In a thrilling final set Djokovic broke back, yet Thiem served for the match at 6-5 only for the world number two to force another tie-break.
Thiem held his nerve to win one of the best O2 matches in many a year, 6-7 (5) 6-3 7-6 (5).
Thiem said: "This was really one of those special matches that I practised all my life for, beating a legend of our game and qualifying for the semi-finals."
The group-stage match between Federer and Djokovic was already hotly-anticipated, with it being their first meeting since July's dramatic Wimbledon final. Now it takes on huge significance.
Djokovic is still jousting with Rafael Nadal to end the year top of the rankings while he is attempting to draw level on six ATP Finals wins with Federer, who is looking to reach the semi-finals for a 16th time in 17 appearances.
Djokovic branded Thiem's performance "phenomenal": "It's a round-robin system, so I'm still in the tournament.
"Head-to-head with Roger. Winner goes to semis. Loser doesn't qualify. As simple as that."
Federer maintains it took him a matter of days to get over the agony of that Wimbledon final defeat by Djokovic.
Now, 123 days since the 20-time grand slam champion failed to convert two championship points on serve before losing a fifth-set tie-break, he will get the chance to prove it.
"We'll find out, but I think it's all flushed away from my side," said Federer. "A lot of water has gone under the bridge since then.
"We have played a lot of matches since, and I think we both look back at a great match.
"I think we both can take away some confidence from the match – him obviously a lot, me maybe a bit less.
"But at the end of the day, I don't know, I wasn't hoping he would not be in my section or in my draw. I didn't hope I was never going to play him again.
"Actually, it's good for me to play him again, and maybe that all helps to get a chance to get him back or whatever it is.
"But at the end of the day, I'm here for the World Tour Finals and not because of the Wimbledon final.
"It's logical to be asked, it's fine, but I'm personally excited to play against Novak on Thursday."
Tuesday's earlier action saw Britain's Joe Salisbury and American partner Rajeev Ram beat Ivan Dodig and Filip Polasek after a match tie-break to give themselves an opportunity of reaching the last four in the doubles.
No Data Analysis info