Rio Olympics 2016: Games end in blaze of colour, Japan takes the baton
Fireworks explode at the 'Heroes of the Games' segment during the event. Photograph: (Getty)
After a rollercoaster fortnight which mixed off-field hitches with compelling sporting drama, Olympics chief Thomas Bach hailed a "marvellous" Games in the Brazilian city.
"These were marvellous Olympic Games in the marvellous city," said Bach, as he declared the Games closed and the Olympic flame was extinguished.
"These Olympic Games are leaving a unique legacy for generations to come. History will talk about a Rio de Janeiro before and a much better Rio de Janeiro after the Olympic Games."
Japan's Prime Minister Shinzo Abe made a comical cameo as Nintendo video game character Super Mario as Tokyo set out its store for 2020.
"The Japanese government will... work hard so it will be the best Olympics ever," Abe said.
Security scares and logistical problems were a feature of South America's first Olympics, held against the backdrop of Brazil's political and economic crisis.
Swathes of empty seats caused disquiet but the Games also witnessed the last hurrahs of both Usain Bolt and Michael Phelps, who both lived up to their billing.
Bolt sealed the sprint 'triple triple' in his final Games, reaching a record-equalling nine gold medals with his third consecutive 100m, 200m and 4x100m sweep.
Swim legend Phelps took his unmatched career haul to 23 gold medals with another five in Rio plus a silver, after his loss to former childhood fan Joseph Schooling.
Brazil came late to the party but the country celebrated long and loud when Neymar won a gold-medal penalty shoot-out against Germany to erase memories of their 7-1 World Cup semi-final humiliation in 2014.(AFP)