The United States finished top of the tally with 39 gold medals, one more than rivals China at 38 and Japan at 27
Tokyo doused its Olympic flame on Sunday in a ceremony that echoed the restraint of a Games held without spectators and transformed by the global pandemic, dazzling sport and deeply person turmoil.
After postponing the Tokyo 2020 Games for a year, organizers said the event would serve as a symbol of world triumph over the pandemic. But with strict pandemic countermeasures and as Covid-19 variants have surged back around the world, the Olympics fell short of the triumph and financial windfall Japan had wanted.
The ceremony, although lustreless, gave athletes something of a glimpse of everyday Tokyo life as the Olympic Stadium was transformed into a park with grass, buskers and BMX riders.
The scene was meant so the visitors could "experience Tokyo", organizers said, a poignant reminder of the many restrictions of the Games.
It was a duly odd ending to an unprecedented event. Japan is now saddled with a $15 billion bill, double what it initially expected, and with no tourist boom.
The president of the International Olympic Committee thanked the Japanese people and acknowledged the difficulty of staging the Games during the pandemic.
"For the first time since the pandemic began, the entire world came together," Thomas Bach said. "Nobody has ever organized a postponed Games before."
Public anger over the pandemic response and a slow-to-start vaccine roll-out have badly damaged Japanese Prime Minister Yoshihide Suga's standing. Public opinion polls showed most Japanese opposed holding the Games during the pandemic.
Still, organizers appear to have prevented the Tokyo Games from spiralling into a Covid-19 superspreader event, notable given that some 50,000 people came together amid the pandemic.
In a sign of the measures, winners accepted their prizes from trays, putting the medals around their own necks, although social-distancing protocols such as preventing hugging were largely ignored throughout the Games.
While the bubble - the set of venues and hotels to which Olympic visitors were largely confined - appeared to hold, elsewhere some things fell apart. Fuelled by the Delta variant of the virus, daily infections spiked to more than 5,000 for the first time in Tokyo, threatening to overwhelm its hospitals.
Japan's record medal haul also helped to take out some of the sting for organizers. The United States finished top of the tally with 39 gold medals, one more than rivals China at 38 and Japan at 27.
The Games also showcased the Olympics' push for more diversity.
For the first time, a victory ceremony was held for both the women's and men's marathon event. The Kenyan anthem filled the 68,000-capacity stadium twice, for gold medallists Peres Jepchirchir and Eliud Kipchoge.
Cold war and 'twisties'
And when they came, the Games themselves provided plenty of high drama.
In a moment more reminiscent of the Cold War, Belarusian sprinter Krystsina Tsimanouskaya refused to board a flight home after she was taken to the airport against her wishes. She has since sought refugee status in Poland.
US superstar gymnast Simone Biles shocked the world when she pulled out of five of her six events, including abruptly abandoning the women's team final after attempting just one vault, citing concerns for her mental and physical health.
Her frank admission, combined with earlier comments by Japanese tennis star Naomi Osaka, brought a sharp focus on issues of athletes' mental health.
In athletics, Italy provided a different kind of shock with their amazing run. Their wins included a stunning gold in the men's sprint relay, taking their athletics gold tally to five.
In swimming, a United States team without 23-time Olympic gold medallist Michael Phelps still ended the meeting on top of the medals table.
Capping five years of intense preparations for athletes, some of them stretched out on the grass laid down in the stadium. Some appeared to relax as they watched a volley of fireworks light up the Tokyo sky.
In the end, two massive screens stadium projected a retro display that called back to the 1964 Tokyo Olympics: the word "Arigato" or "thank you".