A dejected Novak Djokovic said his game fell apart after he saw his dreams of an Olympic gold medal and a Golden Slam go up in smoke in Tokyo.
The world number one was looking to become the first man in history to win all four grand slam titles and Olympic singles gold in the same year but Alexander Zverev fought back brilliantly after losing the first set to win 1-6 6-3 6-1.
It is the third time Djokovic has lost in the semi-finals at the Olympics, with his only medal so far a bronze in Beijing in 2008.
The 34-year-old still had a chance to win gold in mixed doubles with Nina Stojanovic but a miserable day was complete when they were beaten 7-6 (4) 7-5 by Russian Olympic Committee duo Aslan Karatsev and Elena Vesnina.
"I feel terrible," said Djokovic, who refused to blame the incredibly humid conditions.
"It's just sport. He played better. You've got to give him credit for turning the match around. He served extremely well. I was not getting too many looks at the second serve.
"My serve just drastically dropped. I didn't get any free points from 3-2 up in the second. My game fell apart."
Djokovic must try to rouse himself for two shots at a bronze medal on Saturday. He will face Spain's Pablo Carreno Busta in the singles before he and Stojanovic take on Ashleigh Barty and John Peers of Australia.
Djokovic refused to comment on the state of his body, saying of his hopes of rousing himself for another big effort: "Let's see. I feel terrible right now. Tomorrow hopefully fresh start, recover, and at least win one medal for my country."
Zverev will take on Karen Khachanov of the Russian Olympic Committee for the gold medal, and he was in tears on the court afterwards.
The two shared a warm embrace at the net, and Zverev said: "I told him that he's the greatest of all time, and he will be.
"I know that he was chasing history, is chasing the Golden Slam and was chasing the Olympics, but in these kind of moments me and Novak are very close.
"I feel sorry for Novak, but he's won 20 grand slams, 550 Masters series or whatever, you can't have everything.
"It's an amazing feeling knowing that you're going to bring the medal back to your house, back home to Germany. It seemed it was impossible to beat him at this event, so I'm very happy right now. But yet there's still one match to go."
Djokovic had breezed through to the last eight, losing just two games against Kei Nishikori in the quarter-finals, but Zverev has also been playing well and this always looked like the biggest hurdle.
Djokovic's other big opponent was the humidity, with which he has never coped well. He persuaded organisers to shift the start of play back from 11am to 3pm to avoid the worst of the heat but conditions were still extremely difficult despite the match not beginning until nearly 5pm.
The Serbian, who was on a 23-match winning streak taking in French Open and Wimbledon titles, looked set for another easy victory when he raced through the opening set and broke Zverev for 3-2 in the second.
But from there the match turned on its head, the powerful German beginning to achieve the seemingly impossible of hitting through his opponent as he won a remarkable eight games in a row.
Djokovic, who can still become the first man in more than half a century to win the calendar Grand Slam by lifting the US Open trophy, finally stopped the rot to hold for 1-4 in the decider but a lacklustre final game showed he knew the match was up.
Khachanov earlier continued his fine form after reaching the quarter-finals of Wimbledon with a 6-3 6-3 victory over Carreno Busta.
The first tennis gold medal went to Wimbledon champions Nikola Mektic and Mate Pavic in the men's doubles after they beat countrymen Marin Cilic and Ivan Dodig, with both results the best for Croatia in Olympic tennis.
Marcus Daniell and Michael Venus won the first tennis medal for players representing New Zealand while, in the mixed final, Karatsev and Vesnina will take on fellow ROC players Andrey Rublev and Anastasia Pavlyuchenkova.