Zverev is a two-time champion in Munich but the world No.6's quest for a third title ended at the hands of the 27-year-old Belarusian.
The German looked set for a straight-sets win after taking the opener on a tie-break and then breaking Ivashka's serve for a 5-4 lead in the second set.
But Ivashka took the next three games to force a decisive set and then claimed the telling break of serve in the eighth game of the third, having been broken by Zverev in the previous game.
"This match was really tough for me and I was [close to losing] in the second set," Ivashka said in his post-match interview.
"I managed well and I tried stay in and fight until the last moment to see if he would give [me] chances and it happened."
He will face Jan-Lennard Struff in the semi-finals after he came through a three-setter with Filip Krajinovic.
Rain meant the quarter-finals between Nikoloz Basilashvili and Norbert Gombos and John Milman and Casper Ruud could not be completed.
At the Estoril Open, Marin Cilic progressed as Kevin Anderson was forced to retire from their clash with an adductor injury after the first set tie-break, which was won by Cilic.
Cilic will meet Cameron Norrie, who overcame Cristian Garin in two hours and 28 minutes for his fifth top-30 win of the season, in the last four.
The other semi-final will be an all-Spanish affair after Albert Ramos-Vinolas and Alejandro Davidovich Fokina each defeated French players in Corentin Moutet and Ugo Humbert.