He had to save a match point in the 10th game of the decider before breaking and holding to make the last-16 where he will face either French 15th seed Lucas Pouille or Russia's Karen Khachanov.
Fourth seed Grigor Dimitrov struggled to discover his touch and lost 7-6 (4) 6-2 6-4 to Spanish claycourt specialist Fernando Verdasco.
Thiem made the semifinals previous year and in 2016.
Djokovic, seeded 20th, becomes the only player to have reached the last 16 of the French Open at each of the last nine editions. The first occasion was at Wimbledon past year. They won their 14th Grand Slam title in doubles at the All England Club.
Djokovic, who won the French Open in 2016, showed serious determination in outlasting Bautista Agut in a match that lasted three hours, 48 minutes.
"Trust me, in that moment when I do it, I don't think about how it can help me", the smiling Serbian said when asked about the incident. After losing a point during the second-set tiebreaker, 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. Bautista Agut, he's not going to hand you the win.
Beaten Djokovic says may he skip Wimbledon
Djokovic won the tournament in 2011, 2014 and 2015 but has failed to make it beyond the quarter-finals in the past two years. The 10th seed produced a clinical performance to down Kasatkina 6-3, 6-1 on Court Philippe Chatrier, firing 17 winners.
Spain's Fernando Verdasco celebrates after defeating Bulgaria's Grigor Dimitrov during their third round match of the French Open tennis tournament at the Roland Garros stadium, Friday, June 1, 2018 in Paris.
The second seed came from two sets to one down to beat Dusan Lajovic in the second round on Wednesday and had to do the same again two days later to break new ground at Roland Garros.
At that point Zverev woke up and stole back the victory in the fourth and fifth sets, winning the fourth set's tie break.
Dzumhur was so in the zone he failed to notice a ball boy advancing to collect a ball as the Bosnian went to grasp it, leaving the youngster floored and looking out for the count with Zverev on the ropes.
But the 31st-seeded Buzarnescu, a Romanian with a PhD in sports science, continued the surge that has seen her rise almost 350 spots in the rankings over the past year.
No. 19 seed Kei Nishikori of Japan also continued his strong run on Friday, beating Gilles Simon in straight sets - his third straight win over a Frenchman to start the tournament.
England show World Cup promise in home victory over Nigeria
If you look at the Federation Internationale de Football Association ranking, you will see there are teams who are better than us. The players want to do well - you can see from how they play, the change in system to five at the back.
Catch up on what was happening on and off court at Roland Garros in the daily diary from Paris.
But he has never reached a Grand Slam quarter-final, although the longer best-of-five format has worked twice in his favour now at Roland Garros.
This is just the second time that Zverev has reached the final 16 at a Grand Slam, after Wimbledon past year.
After Zverev ran away with the first set, Dzumhur deployed an array of deft drop shots to drag the lanky German to the net, where he was less effective.
World number 29 Dzumhur also served for the match in the fourth set, but Zverev clung on and claimed a 6-2, 3-6, 4-6, 7-6 (7/3), 7-5 victory.
He then broke his opponent and served out the set and match, winning it 7-5 to win his second five-set match in a row.
DragonBall Fighter Z, Fortnite and Overcooked 2 coming to Switch at E3
Meanwhile, VentureBeat said there have been speculations that " Paladins " will be released on the Nintendo Switch . The leaked photo also shows several other video games that are supposed to be arriving on the Nintendo Switch .
"It was an fantastic, high level match", said Zverev after his first-ever win on Chatrier.