Dimitrov was far from his best in the first set, dropping his serve twice against French qualifier Herbert.
The 26-year-old Bulgarian rallied back in the second set with consecutive breaks before serving out to love.
Dimitrov secured a crucial break in the fifth game of the decider and went on seal a third-round spot with a powerful forehand, which world number 82 Herbert returned long.
Fifth seed Thiem produced a battling display to save a match point and beat Andrey Rublev 5-7 7-5 7-5 in the second round.
Thiem led 4-1 in the final set before his 20-year-old Russian opponent recovered and was one point away from victory at 5-4 and 40-30 but hit a forehand narrowly wide.
Thiem, a twice French Open semi-finalist, regained his timing to break back against Rublev before another break in the 12th game secured victory.
The 24-year-old Austrian, who is returning from a five-week absence due to an ankle injury, next faces former world number one Novak Djokovic or Croatia’s Borna Coric for a quarter-final berth.
“I was 10 centimetres from being out of the tournament,” Thiem said.
“But I’m happy that I played two hours and 40 (minutes). I’m looking forward to watching Djokovic and Coric in front of the TV, and then playing the winner on Thursday.”
Last year’s semi-finalist Lucas Pouille blew a one-set lead to suffer a shock 2-6 6-1 7-6(3) defeat to German serve-and-volleyer Mischa Zverev.
Germany’s Alexander Zverev recovered from a slow start to claim a 4-6 6-3 6-2 win over Gilles Muller of Luxembourg.