The Swiss maestro was hoping to tune up for Wimbledon with victory in the grass court tournament he has made his own but instead found the promising home hope in inspired form.
The 19-year-old won 7-6 5-7 6-3 in two hours and six minutes to reach the final of an ATP World Tour event for the second time this year.
"It's unbelievable to get a win against Roger, especially on grass," he told the official ATP World Tour website.
It was the first time that Federer had failed to reach the Halle final in 11 straight appearances, but he came into the tournament after skipping the French Open with a back injury.
Zverev will play fellow German Florian Mayer for the title Sunday.
Mayer upset in form Dominic Thiem of Austria 6-3 6-4 in the second semifinal.
The 38th-ranked Zverev dropped just four points on his serve in the opening set before clinching it in the tiebreak.
17-time grand slam winner Federer, bidding for his first title of 2016, hit back on a single break to level by taking the second set and put the youngster under pressure at the start of the decider.
But Zverev rode the storm and a gained a decisive break to lead 4-2, holding on to his advantage to clinch a memorable victory.
The other major grass court warm up event at the Queen's Club in London saw world number two Murray reach the final with a three-sets win over Marin Cilic.
Murray, bidding for a record fifth title at the tournament, won 6-3 4-6 6-3 and will play big-serving Milos Raonic of Canada, who saw off Australia's Bernard Tomic 6-4 6-4 in the second semifinal.