Spain's Pablo Carreno Busta beat the world No.1 6-4 6-7 (6-8) 6-3 to finish third in men's singles.
The shock result followed a day on from Djokovic's hopes of a golden slam being crushed by defeat to Alexander Zverev in the semi-finals.
In the wake of his singles third-place match setback, Djokovic also pulled out of the mixed doubles bronze match, citing a left shoulder injury.
Having already clinched the Australian Open, French Open and Wimbledon titles, Djokovic was eyeing gold at the Games before heading to the US Open in August, aiming to land the five biggest prizes in tennis in the same season.
That has never been achieved in a calendar year by a man, and Djokovic could not even manage a consolation prize from his singles mission in Japan. How serious his injury is now remains to be seen.
After levelling the singles match by taking the second-set tie-break, Djokovic boiled over in the first game of the decider, firstly when flinging his racket several rows back from the middle of the court after Carreno Busta put away a volley at the net.
Djokovic picked another racket from his bag but petulantly demolished that against a net post after dropping the third game to slide 3-0 behind, receiving a warning from the umpire for that violent outburst.
His anger may have been explained by injury or by his disappointment on Friday, when, as well as losing to Zverev, Djokovic and Serbian team-mate Nina Stojanovic were beaten in the semi-finals of the mixed doubles.
Djokovic would have had one final shot at a medal from his Tokyo trip to come later on Saturday, with the 34-year-old and Stojanovic due to face Ash Barty and John Peers in another match for bronze.
However, shortly after his singles exit, it was announced that Djokovic had pulled out of that match, handing Barty and Peers the medal.
Amid the anger and frustration exhibited on court by Djokovic, it was a banner day for Carreno Busta, as Spain celebrated another tennis medal, having won at least one in eight of the past nine Olympics.
The 30-year-old fell to the court in joy at the end of the two hours and 47 minutes it took him to defeat the world No.1, his elation a sharp contrast to the emotions of his beaten opponent.