Nadal is on a double mission in London – aiming to win the end-of-season event for the first time in his illustrious career and to secure the year-end number one spot.
Russia’s Medvedev, who has won two Masters titles this season, took the first set on a tie-break to leave Nadal staring down the barrel.
The Spanish veteran broke his 23-year-old opponent early in the second set, repeating the trick to level the match.
But Medvedev was quickly into his stride in the decider, sprinting to the net to dispatch a cross-court backhand past his opponent and earn a double break.
Nadal, who came into the tournament under an injury cloud, avoided the embarrassment of a “bagel”, which looked a distinct possibility at one stage.
The 19-time Grand Slam champion fended off a match point on his own serve and then, roared on by the crowd, broke Medvedev twice to level the match at 5-5 and edged ahead 6-5.
But just when it seemed Medvedev was slipping inexorably towards defeat, he managed to hit the reset button and hold to take the third set into a tie-break.
Medvedev was first to falter in the shootout, hitting a regulation forehand wide to hand Nadal two match points and he sealed the win on the next point.
The Spaniard has qualified 15 straight times for the ATP Finals but has never clinched the title, won a record six times by Roger Federer and five times by Djokovic.
In the evening match on Wednesday the two youngest players in the top 10 of the ATP rankings square off, with Stefanos Tsitsipas, 21, taking on defending champion Alexander Zverev, who is 22.
Zverev beat Nadal on Monday for his third consecutive victory at the eight-man ATP Finals against the “Big Three”, dating back to last year’s tournament.
Tsitsipas beat Medvedev for the first time in his career.
Dominic Thiem has already secured one of the qualification spots in Group Bjorn Borg, leaving Roger Federer and Djokovic to scrap it out on Thursday for the remaining place from the four-man pool.