The Rio Olympics ended with a spectacular closing ceremony Sunday officially handing over control for the 2020 Olympics to Tokyo. Spectators, athletes and officials braved strong winds and rains to attend the carnival-inspired ceremony.

Closing Ceremony in the rain People watch the Rio 2016 Olympics closing ceremony in the rain at the Olympic Boulevard live site, Aug. 21, 2016. Photo: CHRIS MCGRATH/GETTY IMAGES

The ceremony began 8 p.m. local time (7 p.m. EDT) at the Maracana stadium and featured parades, dances, performances by Samba legend Martinho da Vila, electronic music artist Kygo and singer Julia Michaels, human formations of Rio’s iconic landmarks Christ the Redeemer and Sugarloaf Mountain and an impressive showcase by Tokyo.

Pita Taufatofua of Tongo Olympians Kaori Icho of Japan, Pita Taufatofua of Tongo and Yusra Mardini of the Refugee Olympic Team dance on stage during the Closing Ceremony on Day 16 of the Rio 2016 Olympic Games at Maracana Stadium on Aug. 21, 2016. Photo: EZRA SHAW/GETTY IMAGES

Kim Jong Un impersonator in Rio Kim Jong-un impersonator Howard attends the Closing Ceremony on Day 16 of the Rio 2016 Olympic Games at Maracana Stadium, Aug. 21, 2016 Photo: CAMERON SPENCER/GETTY IMAGES

“These were a marvellous Olympics, in a marvellous city,” International Olympic Committee chief Thomas Bach reportedly said. “Over the last 16 days a united Brazil inspired the world, in difficult times for all of us, with its irresistible joy for life.”

flag handover (Left-Right) Mayor of Rio de Janeiro Eduardo Paes, IOC President Thomas Bach and Governor of Tokyo Yuriko Koike take part in the Flag Handover Ceremony during the Closing Ceremony on Day 16 of the Rio 2016 Olympic Games at Maracana Stadium, Aug. 21, 2016. Photo: CAMERON SPENCER/GETTY IMAGES

Bach was reportedly on the receiving end of boos of sadness when he officially closed the 31st Olympic Games. Rio’s mayor Eduardo Paes returned the Olympic flag to Bach who then handed it over to Tokyo governor Yuriko Koike officially signaling the transition to the 2020 Olympics.

Abe cosplay Japan Prime Minister Shinzo Abe appears during the 'Love Sport Tokyo 2020' segment during the Closing Ceremony on Day 16 of the Rio 2016 Olympic Games at Maracana Stadium, Aug. 21, 2016. Photo: DAVID RAMOS/GETTY IMAGES

Tokyo nearly stole the show with its impressive showcase featuring popular fictional characters like Hello Kitty, Doraemon, Pac-man and Mario from Nintendo’s famous Mario game franchise. Japanese Prime Minister Shinzo Abe popped out of a green pipe dressed as Mario. The showcase ended with Abe holding up a glowing red ball representing Japan’s rising sun.

Simone biles Flag bearer Simone Biles of the U.S. walks during the 'Heroes of the Games' segment during the Closing Ceremony on Day 16 of the Rio 2016 Olympic Games at Maracana Stadium, Aug. 21, 2016. Photo: EZRA SHAW/GETTY IMAGES

U.S. topped the final medal table winning 121 medals in total: 46 gold, 37 silver and 38 bronze medals.  Gold medalist Simone Biles carried the U.S. flag during the ‘Heroes of the Games’ segment at the closing ceremony.

Izabel Goulart Model Izabel Goulart and Renato Sorriso dance during the Closing Ceremony on Day 16 of the Rio 2016 Olympic Games at Maracana Stadium on Aug. 21, 2016. Photo: CAMERON SPENCER/GETTY IMAGES

Brazilian model Izabel Goulart led the parade featuring 50 women and 200 dancers and a sound truck with 12 carnival queens. The ceremony ended with a confetti and fireworks show.

fireworks Fireworks explode during the Closing Ceremony 2016 Olympic Games at Maracana Stadium, Aug. 21, 2016. Photo: BUDA MENDES/GETTY IMAGES