The Rio Olympics ended with a spectacular carnival-inspired closing ceremony, and the official handover to 2020 hosts Tokyo.
The colourful ceremony, lasting almost three hours, celebrated Brazil's arts and was held in a wet Maracana.
Among the highlights were Tokyo's impressive showcase and a vibrant carnival parade.
"These were a marvellous Olympics, in a marvellous city," said International Olympic Committee chief Thomas Bach.
"Over the last 16 days a united Brazil inspired the world, in difficult times for all of us, with its irresistible joy for life."
Bach officially closed the Games of the 31st Olympiad after 16 days of competition, featuring 11,303 athletes from 206 nations and a refugee team.
One of the biggest cheers of the night came when Japan's Prime Minister Shinzo Abe appeared dressed as computer game character Super Mario, rising out of a huge green pipe in the stadium.
The ceremony, watched by billions around the world, featured the parade of athletes and a dramatic extinguishing of the Olympic flame.
What happened?
- The Maracana was turned into a street carnival as the ceremony celebrated Brazil's art, music and dance.
- Highlights included human formations of iconic Rio landmarks Christ the Redeemer and Sugarloaf Mountain.
- The Olympic flame was extinguished by a rain shower, which then gave life to a large tree sculpture to symbolise rebirth.
- The Rio carnival anthem 'Cidade Maravilhosa' played as the party reached a crescendo.
- Brazilian model Izabel Goulart led a parade of 50 women and 200 dancers, who were joined by a sound truck containing 12 carnival queens.
- The ceremony concluded with a confetti and firework show.
Tokyo's time comes
The ceremony featured the symbolic handover of the Olympic flag. Rio mayor Eduardo Paes returned it to IOC president Bach, before it was passed to Tokyo governor Yuriko Koike.
That was followed by an impressive 12-minute showcase of Tokyo, which included Prime Minister Abe's star turn.
Who said what?
IOC president Thomas Bach: "Brazil we love you, thank you for your warm hospitality. Over the last 16 days a united Brazil inspired the world, in difficult times for all of us, with its irresistible joy of life. You gave many reasons to be proud. These Games demonstrated that diversity is an enrichment for everyone. These Games were a celebration of diversity.
"These were a marvellous Olympic Games in a marvellous city. They are leaving a unique legacy for many generations to come. History will talk about a Rio before and a much better Rio after these Games."
Rio 2016 organising committee president Carlos Arthur Nuzman: "The Games in Rio is a great challenge, but a challenge with success. I am proud of my country, my city and my people. Rio has delivered history."