Japan will douse its more than year-old Olympic flame on Sunday, closing out a Tokyo Games that were upended by the pandemic and transformed by the drama of politics, dazzling sport and deeply personal turmoil.
For the host nation, the Olympics fell short of the global triumph and financial blockbuster it once sought.
Still, organisers appear to have prevented the Games from spiralling into a Covid-19 superspreader event, a remarkable achievement given that some 50,000 people came together amid the pandemic.
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.
Normally one of the world's most electric cities, Tokyo is under a state of emergency, depriving it of the manic buzz of an Olympic host or the fervent crowds of its last Olympics in 1964.
"We can already now say with confidence that we have experienced a very successful Olympic Games considering all the uncertainties we had the last two years," International Olympic Committee President Thomas Bach told committee members hours before the ceremony.
While opinion polls showed most Japanese opposed the Games, would-be spectators still came out in force, defying authorities and blistering heat to peek in from overpasses as they tried to catch a glimpse of outdoor events such as the triathlon or new sports such as skateboarding.
Their numbers appeared to be bolstered by enthusiasm over Japan's medal haul.
China and the United States were tied for the top of the tally with 38 golds as of midday on Sunday, with Japan at 27.
Thirteen golds were up for grabs on Sunday before the closing ceremony, including in the men's marathon, won by Kenya's Eliud Kipchoge, and women's basketball, which went to the United States.
Japan is due to hand over the Olympic baton to the next host city, Paris, at a ceremony that starts at 8pm JST (1100 GMT).
Cold war and 'twisties'
After a year's delay and often against the backdrop of cavernous, nearly empty venues, the Games themselves provided plenty of high drama.
That culminated with the defection of Belarusian sprinter Krystsina Tsimanouskaya who, in a moment more reminiscent of the Cold War, 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.
The 24-year-old spoke with candour about struggling to deal with the weight of expectation placed on her and made the world aware of the "twisties", a type of mental block that prevents gymnasts from performing their gravity-defying skills.
Biles ultimately came back to win the bronze on the balance beam in the final event of the women's gymnastics programme, a moment of triumph that crystallised her transformation from Olympic champion to advocate for mental health.
In athletics, Italy provided a different kind of shock with their amazing run. Their victories included a stunning gold in the men's sprint relay, taking their athletics gold tally to five.
In swimming, the United States were without 23-time Olympic gold medallist Michael Phelps for the first time since the Atlanta Games in 1996, and while their gold count slipped, they still ended the meet on top of the medal table with 30 in total.
But they were pushed close by the Australian team who achieved their best ever haul of nine golds and 21 medals overall, eight of their titles won by their astonishing women's team.
As the Games wind up, Japan will now be left to count the cost. The bill for the Olympics and Paralympics is expected to be 1.64 trillion yen ($15 billion), 22 per cent higher than it was before the Games were delayed in 2020, and twice as much as the 800bn yen estimate Tokyo submitted in its host bid.
The bill, which will have to be fully paid after the Games end, is most likely to be settled by the Tokyo government and the central government.