Rio on Sunday closes a Paralympic Games that many feared would be a fiasco but which turned into a triumph, though marred in the final hours by the death of an Iranian cyclist.
Eleven days of competition where China dominated the medals table, followed by Britain, Ukraine and the United States, were ending Sunday with the last few events, including marathons and wheelchair rugby.
At the closing ceremony in Rio de Janeiro's Maracana football stadium Brazilian officials were officially to hand over to Tokyo for the 2020 Olympic and Paralympic Games.
The upbeat mood in Rio however was darkened late Saturday by the death of Iranian cyclist Bahman Golbarnezhad, 48.
The athlete, who wore a prosthesis on his left leg, fell during a mountainous descent in the road race and died before he could be treated in hospital.
Philip Craven, the International Paralympic Committee president, called the tragedy "truly heart-breaking."
The Iranian flag flew at half mast in the Athletes' Village and a minute's silence was planned at the closing ceremony.
Nevertheless, Rio was expected to put on a dazzling show at the Maracana, featuring Brazil's rich music and dance culture to celebrate a far better Paralympics than many had believed possible.
"This will be a time for celebration..., a final act," said the ceremony's producer Flavio Machado, who promised "many Brazilian musicians on stage."
The Japanese say that the Rio Games have set a high standard for them to follow.
"We have been impressed by our experience across both the Olympic and Paralympic Games and inspired by the passion of the Carioca," said Toshiro Muto, CEO of the Tokyo 2020 Organizing Committee, referring to Rio residents by their nickname.
There had been fears that this wouldn't be at all how the Rio Games ended.
Even before they started, the Rio organizers' woeful finances in the wake of the August Olympics and a stunning lack of interest in tickets raised fears of failure.
Then on the eve of the Paralympics, the Brazilian Senate pushed president Dilma Rousseff out of office in a bitter impeachment battle that left the country more distracted than ever. Her replacement and fierce enemy Michel Temer came to the opening ceremony on September 7 and was booed by the crowd.
There were also international tensions over a ban imposed by the International Paralympic Committee on the entire Russian team because of alleged state doping.
But then things got better. The opening ceremony moved viewers with its exuberant set design and the unrestrained joy of the parading athletes.
And while the stadiums and arenas were initially empty, the rhythm soon picked up, with noisy and passionate Brazilian fans providing world class atmosphere.
By the end, officials said Saturday, they had sold 2.1 million tickets -- less than London in 2012 but more than Beijing four years earlier. Part of that success, however, was due to many tickets being sold for as little as three dollars -- or given to school children in an international fill the seats campaign.
The gap between the Olympic and Paralympic performances is gradually blurring with disabled athletes breaking records after records in Rio.
Among the stars were Brazil's swimmer Daniel Dias who added four golds, three silvers and two bronzes to his existing medal haul from Beijing and London which has won him descriptions as the Michael Phelps of the Paralympics.
There was amazement in the 1,500m track race when Algeria's Abdellatif Baka set a new record that was actually faster than the winning time by Olympic gold medalist Matthew Centrowitz in the same stadium a month earlier. However, Centrowitz won in what was by Olympic standards a near record slow race, meaning Baka's outstanding time was of mostly symbolic significance.
Once more it was China that dominated overall, with almost 100 medals more than its nearest rival, Britain, which held a comfortable second place.
The big country missing in the top section of the standings, however, was Russia which during the London Games won 102 medals, including 36 golds.