Rafael Nadal saved a match point to beat Russian Daniil Medvedev and boost his hopes of a first ATP Finals title.
Nadal, bidding to keep his world number one ranking, could have been eliminated on Wednesday with defeat but beat the fourth seed 6-7 (3-7) 6-3 7-6 (7-4).
The Spaniard trailed 5-1 in the third set and saved match point on his serve at 5-2 before a stunning comeback.
"This match is one of those that one [time] out of 1,000 you win," Nadal said. "Honestly, I was super lucky."
The 33-year-old's hopes of progression to the semi-finals rest on his meeting with Stefanos Tsitsipas on Friday.
Greek Tsitsipas plays Alexander Zverev, who beat Nadal in their opening round-robin match, later on Wednesday.
Nadal shows trademark fighting spirit
The last meeting between Nadal and 23-year-old Medvedev was September's US Open final, which the Spaniard won in five sets, and this match was almost as thrilling.
Both players looked beaten at times, Medvedev when he was distracted while he was losing the second set and Nadal when a double-break down in the decider.
Errors from Nadal and a resurgence from Medvedev at the start of the third set had led to the Russian racing into a 4-0 lead.
He had two break points for 5-0, and the match point two games later, but 19-time Grand Slam champion Nadal showed all of his trademark fighting spirit, roared on by the crowd at London's O2 Arena.
As Nadal clawed his way back, Medvedev lost focus again, sarcastically giving a thumbs-up to his box as games slipped away.
After losing five successive games, the Russian settled himself to force a tie-break and was on serve at 4-5 in the breaker before he dragged a short forehand wide to give Nadal a mini-break and match point.
Another gruelling rally followed but a Medvedev shot that was originally called in was ruled out by Hawk-Eye to hand Nadal victory after two hours 49 minutes.
Semi-final and ranking permutations
The win means even if Nadal loses his final match and does not qualify for the semi-finals, Novak Djokovic will have to win the tournament to overtake him as year-end world number one.
Nadal can also secure the position at the top of the rankings if he wins his final group match and makes the final, regardless of Djokovic's results.
The Serb plays Roger Federer on Thursday in Group Bjorn Borg with the winner progressing to the last four and the loser eliminated.
The winner of the match between Tsitsipas and Zverev can seal a semi-final spot later on Wednesday (20:00 GMT).
Greece's Tsitsipas is through if he beats Zverev in two sets, while the German will be guaranteed progression with any win.