Zverev had broken Federer’s first service game of the third set and stayed in control, despite Federer’s many polite but firm discussions with the chair umpire.
The 28-time Masters 1000 champion received a point penalty for ball abuse at 0-3 down in the third set.
Both Djokovic and Federer were beaten for the first time in Shanghai quarter-finals after winning a combined 13 matches here at this stage.
“It was a very difficult victory mentally to — I wasn’t really thinking that long term, It just went step by step. It happened.
“I broke him, I won the set, I stayed there, broke him again, eventually I got the win at the end. Yeah, I wasn’t really thinking too much of the future, and I think that helped a lot.“
More from Competition
Andy Murray's miracle comeback from hip surgery lifted to a new level on Saturday the former No. 1 reached his …
Teenaged sensation Coco Gauff kicked off the start of what promises to be a notable career as the 15-year-old won …