Rio has handed hosting duties for the Olympic Games to Tokyo in a colourful and rain-lashed closing ceremony.
Brazil brought down the curtain on the first Olympics to be held in South America - 16 days that saw spectacular sporting achievement but also disappointing crowds, crime and criticism for the organisers.
International Olympic Committee President Thomas Bach hailed the Games as a "marvellous Olympic Games in the 'marvellous city'" before the hosting baton was handed to 2020 hosts Tokyo.
A taster sequence for the forthcoming Japan Games featured bullet trains and Japanese PM Shinzo Abe emerging from a green pipe dressed as Nintendo video game hero Mario.
Many of the athletes wore ponchos as they entered the stadium taking selfies and dancing to music from Brazilian DJs.
Gary O'Donovan carried the flag for Ireland. Gary and his brother Paul won silver in the men’s lightweight double sculls.
Flag bearers from other nations included 4ft 9in gymnastics superstar Simone Biles from the US and South African runner Caster Semenya.
Like so many events during the Rio Games, the closing ceremony took place in front of a half-empty stadium.
The stormy weather also took its toll, with helicopters that were supposed to provide spectacular aerial footage grounded for safety reasons.
High winds and torrential rain caused power cuts in Rio, including near the stadium shortly before the start of the ceremony when power lines came down.
In Pictures: The Rio 2016 Closing Ceremony brings the curtain down on the Olympics
Some athletes cut short their participation. British distance runner Eilish McColgan tweeted: "So we lasted 10 minutes and are on the first bus home! Should of stayed and watched it on the TV!!".
The ceremony featured original footage of Alberto Santos Dumont, the man that Brazilians recognise as the inventor of the aeroplane.
The theme, "Brazilians can do with their bare hands," was a nod to the emerging economy of the world's fifth most populous nation.
Dressed in bright feathers, dozens of dancers formed in the shape of the arches of Lapa, a popular area of Rio akin to Roman ruins, then morphed to make the shape of iconic Sugarloaf before quickly changing again, this time to the official 2016 symbol.
Samba legend Martinho da Vila, sang "Carinhoso," or "Affectionate" and Mariene de Castro seemed to get drenched as she sang to accompany the extinguishing of the Olympic flame.
Fans leaving the stadium said they had not let the bad weather dampen their spirits.
Holly Graham, from the US, said: "Amazing, fantastic, beautiful... absolutely gorgeous. Couldn't be happier."
Manuel David Korn, from Sao Paulo, said: "The cold and the rain got in the way a little bit, but it was beautiful - my daughter loved it."
Download the brand new OffTheBall App in the Play Store & App Store right now! We've got you covered!
Subscribe to OffTheBall's YouTube channel for more videos, like us on Facebook or follow us on Twitter for the latest sporting news and content.