TOKYO — With his Golden Slam bid over for at least another three years, Novak Djokovic rested his head on Alexander Zverev’s shoulder as his German opponent and friend consoled him.

“I told him that he’s the greatest of all time,” Zverev said. “I know that he was chasing history.”

Djokovic, the top-ranked Serb who had seemed invincible in all of the biggest tournaments this year, lost to Zverev 1-6, 6-3, 6-1 Friday in the semifinals of the tennis tournament at the Tokyo Olympics.

Djokovic was attempting to become the first man to win all four Grand Slam tournaments and Olympic gold in the same year. He won the Australian Open, the French Open and Wimbledon this year and needed the Olympic and U.S. Open titles to complete the Golden Slam collection.

Steffi Graf in 1988 remains the only tennis player to achieve the Golden Slam.

“He won 20 Grand Slams,” Zverev said. “So you can’t have everything.

“At the end of the day he’s the greatest of all time, because he’s going to win the most Grand Slams, he’s going to win the most Master Series, he’s going to be the longest at the world No. 1, and I’m sure 99% that this is the case when it’s all said and done,” Zverev said.

Zverev’s opponent in the gold-medal match will be Karen Khachanov. The Russian beat Pablo Carreno Busta of Spain 6-3, 6-3.

Djokovic, who hadn’t lost since getting beaten by Rafael Nadal at the Italian Open final 2½ months ago, will play Carreno Busta for bronze.

On a humid and muggy evening at the Ariake Tennis Park, Djokovic committed a series of uncharacteristic errors after a strong start as the 6-foot-6 (1.98-meter) Zverev started to win free points with his big serve.

When Zverev hit a backhand winner down the line that Djokovic didn’t move for to close it out, Djokovic walked to the net where he received a warm hug from Zverev as the pair exchanged some words.

“Of course I’m happy that I’ve won, but in the end of the day I also know (how) he feels,” Zverev said.

Djokovic’s only Olympic medal was bronze in singles at the 2008 Beijing Games — his first. He could still win a gold at the Tokyo Games in mixed doubles.

Djokovic came back on the court little more than an hour later to play with Serbian partner Nina Stojanovic in the mixed doubles semifinals against the Russian duo of Elena Vesnina and Aslan Karatsev.

It’s the third consecutive day that Djokovic was playing two matches.

Viktor Troicki, Serbia’s Olympic team coach, told The Associated Press on Thursday that the entire team was against Djokovic playing mixed doubles because they didn’t want the event to tire him out with so much on the line in singles.

Djokovic can still go after the calendar-year Grand Slam by winning the U.S. Open — something no man has accomplished since Rod Laver in 1969.

The 34-year-old Djokovic is already the first man since Laver that year to win the first three major tournaments in a season.

Djokovic also already matched his longtime rivals Roger Federer and Nadal by winning Wimbledon this month for his 20th Grand Slam title. He was the only member of the Big Three to travel to Tokyo and Djokovic has been soaking in the OIympic experience like few other athletes.

Without Djokovic, though, the gold-medal match in singles will be lacking star power. Zverev’s best career result was reaching the final of last year’s U.S. Open, while the 25th-ranked Khachanov is coming off a quarterfinal appearance at Wimbledon and is now in the biggest final of his career.

Zverev called it “maybe the proudest moment of my career so far.

“Because I’m not only playing for myself I’m not only playing for my parents, for my brother, for my family,” he added. “But I’m also playing for everybody, all the (German) athletes here back at the base and everybody back at home watching.”

In men’s doubles, the top-seeded pair of Nikola Mektic and Mate Pavic beat Marin Cilic and Ivan Dodig 6-4, 3-6, 10-6 in an all-Croatian final. It was Croatia’s first gold and first silver in Olympic tennis, previously having won three bronzes.

The New Zealand team of Marcus Daniell and Michael Venus took bronze by beating Austin Krajicek and Tennys Sandgren of the United States 7-6 (3), 6-2.

Daniell and Venus became the first New Zealand players to win a medal in tennis since 1912, when Anthony Wilding took bronze in singles while representing Australasia. Wilding, New Zealand’s only Grand Slam singles champion with six titles, was killed during World War I in 1915 at the age of 31.