Djokovic, the world men's No. 1, cruised to win the first set 6-1, but dropped the next two 3-6, 1-6. Before the second set, Djokovic hadn't lost a single set in Olympic play.
The 34-year-old Serbian was in good position to achieve the rare Golden Slam -- winning all four Grand Slam tournaments and Olympic gold in the same calendar year. Only one person has ever accomplished the feat, Steffi Graf in 1988.
Djokovic stormed out to a big lead in the first set, playing with the same unstoppable form that he'd shown throughout the tournament this week.
After going down a break in the second set, Zverev showed his frustration and smashed a ball into the mostly empty stands. At that point, the 24-year-old German, who's ranked No. 5 in the world, turned the tables and used his powerful serve and lethal forehand to win four games in a row and evened the match at one set apiece.
Zverev continued his stunning domination in the third set, racing off to a 4-0 lead before finally sealing the win with a clean backhand winner after just over two hours of play. The 2020 U.S. Open finalist finished the match with 43 winners to Djokovic's 18.
After the match, Zverev lingered on his bench on the sidelines for several minutes, his face buried in a towel.
With the win, Zverev advanced to the gold medal match to play Karen Khachanov of the Russian Olympic Committee on Sunday.
Earlier on Friday, Khachanov defeated Spain's Pablo Carreno Busta 6-3, 6-3.
Djokovic has never won an Olympic gold medal. He took the bronze at the 2008 Olympics in Beijing, was beaten in the bronze medal match at the 2012 Games in London and lost in the first round four years later in Rio de Janeiro. He will play Busta in the bronze medal match.
Although Djokovic's dreams of a Golden Slam ended Friday, he still has a chance to complete the rare Grand Slam if he wins the U.S. Open in September. He won the Australian Open in February, the French Open in June and Wimbledon earlier this month.
No one in men's tennis has won a calendar Grand Slam since Rod Laver of Australia in 1969.
A victory in New York City would also deliver Djokovic's 21st Grand Slam trophy, which would be the most in history in men's tennis. He's presently tied with rivals Roger Federer of Switzerland and Rafael Nadal of Spain, who also hold 20 major titles.