The 21-year-old German looked to be on the brink of another disappointing early exit from a Grand Slam, but he held his nerve to force a tiebreak, which he won comfortably and . eventually prevailed.
World number three Alexander Zverev saved a match point before completing a comeback to beat Bosnian Damir Dzumhur 6-2 3-6 4-6 7-6(3) 7-5 in the third round of the French Open on Friday.
The 21-year-old German looked to be on the brink of another disappointing early exit from a Grand Slam, with 26th seed Dzumhur serving for the match at 5-4 in the fourth set.
But Zverev held his nerve to force a tiebreak, which he won comfortably and eventually prevailed in the final set to book his first trip to the last 16 of the tournament.
Former champion Novak Djokovic battled with Spaniard Robert Bautista Agut to grind out a 6-4 6-7(6) 7-6(4) 6-2 victory.
After losing a point during the tiebreaker in the second set, the 20th-seeded Djokovic angrily whacked his racket into the clay. He regained his composure and broke the 13th-seeded Bautista Agut's serve early in the fourth set to take control.
The 20th-seeded Serb is playing at his lowest seeding in a Grand Slam since 2006 having dropped to 22 in the world rankings but has now reached the last 16 of a major for the 43rd time -- second on the all-time list behind Roger Federer.
Djokovic improved to 7-1 against Bautista Agut. He will next play another Spanish player, Fernando Verdasco.
Djokovic won the last of his 12 Grand Slam titles at Roland Garros two years ago.
Fourth seed Grigor Dimitrov struggled to discover his touch and lost 7-6(4) 6-2 6-4 to Spanish claycourt specialist Fernando Verdasco.
The Bulgarian fell to his seventh consecutive defeat against top 50 opponents at the French Open.
In the women's draw, fourth seed Elina Svitolina's French Open breakthrough was again put on hold as the Ukrainian fourth seed suffered a 6-3 7-5 loss in the third round to Romania's Mihaela Buzarnescu.
Earlier on Friday, U.S. Open runner-up Madison Keys saved two set points in the second set before putting away Japan's Naomi Osaka 6-1 7-6(7) to reach the fourth round.