Nadal faced a match point but the 18-year-old German missed an easy volley - admitting: "On match point I sucked."
Three-time champion Nadal plays Japan's Kei Nishikori next and could face Novak Djokovic in the semi-finals.
Serena Williams beat defending champion Simona Halep 6-4 6-3 to reach the last four in the women's draw.
The world number one now plays Poland's Agnieszka Radwanska, who beat Petra Kvitova 6-2 7-6 and will reclaim the world number two ranking when the new list is released on Monday.
"She knows how to play in big stadiums and big matches, big games," Williams said of Halep.
'He is amazingly talented'
Zverev has been widely tipped as the teenager most likely to make the breakthrough among the game's elite and he went agonisingly close to a landmark win over Nadal.
The 6ft 6in German, the younger brother of tour player Mischa Zverev, led 5-3 and 40-30 in the final set, only to make three straight unforced errors.
Nadal, 29, battled back impressively, but had glowing praise for the teenager, who is set to rise to a career-high ranking of 52 next week.
"He is amazingly talented," said Nadal. "He is probably going to be the number one in the world.
"With his second serve at 120mph, with a lot of spin and at 124, 123, 120mph, it was impossible. If he puts the first serve in at over 130 mph then you are in big trouble.
"So I think that I'm here, and still alive."
Djokovic finds his form
The world number one beat Spain's Feliciano Lopez 6-3 6-3 to set up a quarter-final with Jo-Wilfried Tsonga of France.
Djokovic had not been at his best in the previous rounds but saw off Lopez with little trouble.
"I was very solid. I didn't allow him to come to the net too many times," said the Serb. "It was a good performance."
David Goffin beat French Open champion and third seed Stan Wawrinka 6-3 5-7 7-6 (7-5), while Milos Raonic knocked out sixth seed Tomas Berdych 6-4 7-6 (9-7).
In the doubles, Jamie Murray will rise to the top of the world rankings if he wins his quarter-final later on Thursday. Murray and partner Bruno Soares face Feliciano Lopez and Marc Lopez from 22:00 GMT.