Reigning champion Zverev seemed in control after taking the first set but the third-ranked German made a series of errors as Kecmanovic began to show more resistance.
World number 58 Kecmanovic rallied to win the second set and forced a final-set tiebreak against the top seed.
In chilly, windy conditions in the Bavarian capital, Zverev eventually shook off Kecmanovic after two hours and 18 minutes.
"Today is a very cold day so it was difficult to put on the pressure. At the end of the day, I'm happy I won," Zverev said.
"Now we can get started. I can't play any worse than I did in the second and third sets today. But I played my best tennis in the crucial moments, which is the main thing."
The 28-year-old will face Canada's Gabriel Diallo in the last 16. Zverev has won the Munich title three times, in 2017, 2018 and last year.
Kecmanovic, 26, is the only player other than Jannik Sinner to have defeated Zverev since his semi-final exit at the Australian Open in January. He beat Zverev in the second round in Acapulco in February.
Elsewhere on Tuesday, sixth seed Luciano Darderi beat China's Zhang Zhizhen 7-6 (7/5), 3-6, 6-1, while Denis Shapovalov defeated eighth seed Tallon Griekspoor 6-4, 3-6, 6-2.
Alexander Bublik, Flavio Cobolli and Joao Fonseca also all booked their spots in the second round with straight-set victories.
