The Rio Olympics ended in a blaze of colour with an exuberant closing ceremony on Sunday.

Performers take part in the closing ceremony of the 2016 Rio Olympics.
Performers take part in the closing ceremony of the 2016 Rio Olympics.

The Rio Olympic closing ceremony took place in a blustery storm, a touch of melancholy and a sense of pride on Sunday as Brazil breathed a collective sigh of relief at having pulled off South America's first Games.

Performance dance at the closing ceremony of the Rio 2016 Olympic Games at the Maracana stadium in Rio de Janeiro on August 21, 2016.
Performance dance at the closing ceremony of the Rio 2016 Olympic Games at the Maracana stadium in Rio de Janeiro on August 21, 2016.

Brazil, which battled with empty seats, security scares and a mysterious green diving pool, ended the games with two late gold medals for the host country in its two favorite sports, men's soccer and volleyball. The wins helped smooth some of the rough edges around the Games for Brazilians.

Dancers form the Olympics rings at the closing ceremony of the 2016 Rio Olympics.
Dancers form the Olympics rings at the closing ceremony of the 2016 Rio Olympics.

From the Maracana where it all began 16 days ago, the final event kicked off with figures dressed as multi-colored macaws flying over Rio's world-famous landmarks, Christ the Redeemer and Sugarloaf Mountain, before forming the five Olympic rings.

Dancers perform during the closing ceremony of the Rio 2016 Olympic Games at the Maracana stadium in Rio de Janeiro on August 21, 2016.
Dancers perform during the closing ceremony of the Rio 2016 Olympic Games at the Maracana stadium in Rio de Janeiro on August 21, 2016.

A storm that menaced Rio all day sent wind and rain through Brazil's most storied stadium and the power briefly went out in part of the stadium and the surrounding neighborhood shortly before the ceremony kicked off.

Olympians carrying their countries' flags enter the closing ceremony of the Rio 2016 Olympic Games at the Maracana stadium in Rio de Janeiro on August 21, 2016.
Olympians carrying their countries' flags enter the closing ceremony of the Rio 2016 Olympic Games at the Maracana stadium in Rio de Janeiro on August 21, 2016.

Rain drenched performers and hundreds of athletes as they entered the party, many with medals hanging around their necks.

Athletes take part in the closing ceremony of the 2016 Rio Olympics.
Athletes take part in the closing ceremony of the 2016 Rio Olympics.

To the beat of traditional Brazilian music, Olympians danced and waved their countries' flags to celebrate their place on the world's premier sporting stage. The first Refugee team in Olympic history, one of the biggest crowd-pleasers of the Games, marched in behind the Olympic flag, carried by a Congolese judoka and Rio resident.

(From L) Silver medallist Ethiopia's Feyisa Liesa, gold medallist Kenya's Eliud Kipchoge and bronze medallist USA's Galen Rupp pose on the podium of the men's marathon during the closing ceremony of the Rio 2016 Olympic Games.
(From L) Silver medallist Ethiopia's Feyisa Liesa, gold medallist Kenya's Eliud Kipchoge and bronze medallist USA's Galen Rupp pose on the podium of the men's marathon during the closing ceremony of the Rio 2016 Olympic Games.

In the last of 306 medal ceremonies, International Olympic Committee President Thomas Bach draped the gold around the neck of Kenya's Eliud Kipchoge, 31, who shone with his seventh win in eight marathons, timing 2hr 8min 44sec to win by more than a minute.

The USA Basketball Men's National Team celebrates after winning the Gold Medal Game against Serbia on Day 16 of the Rio 2016 Olympic Games at Carioca Arena 1 on August 21, 2016.
The USA Basketball Men's National Team celebrates after winning the Gold Medal Game against Serbia on Day 16 of the Rio 2016 Olympic Games at Carioca Arena 1 on August 21, 2016.

The USA's basketball 'Dream Team' of NBA stars also claimed the final gold of the Games with a crushing 96-66 win over Serbia.

Spectators take a selfie at the closing ceremony of the Rio 2016 Olympic Games at the Maracana stadium in Rio de Janeiro on August 21, 2016.
Spectators take a selfie at the closing ceremony of the Rio 2016 Olympic Games at the Maracana stadium in Rio de Janeiro on August 21, 2016.

Bach declared the Rio Games closed and expressed hope that they had left a lasting mark on the metropolitan area of 12 million people.

"These Olympic Games are leaving a unique legacy for generations to come," he said. "History will talk about a Rio de Janeiro before and a much better Rio de Janeiro after the Olympic Games."

Brazilian singer Mariene de Castro performs during the extinguishing of the Olympic flame during the closing ceremony of the Rio 2016 Olympic Games at the Maracana stadium in Rio de Janeiro on August 21, 2016.
Brazilian singer Mariene de Castro performs during the extinguishing of the Olympic flame during the closing ceremony of the Rio 2016 Olympic Games at the Maracana stadium in Rio de Janeiro on August 21, 2016.

In a final symbolic act, the Olympic flame that had burned since August 5 was then extinguished in a downpour of artificial rain. The city handed over the Olympic flag to Tokyo, site of the 2020 Summer Games.

The Governor of Tokyo Yuriko Koike (R) waves the Olympic flag next to the International Olympic Committee (IOC) President Thomas Bach (C) and the Mayor of Rio Eduardo Paes during the closing ceremony of the Rio 2016 Olympic Games.
The Governor of Tokyo Yuriko Koike (R) waves the Olympic flag next to the International Olympic Committee (IOC) President Thomas Bach (C) and the Mayor of Rio Eduardo Paes during the closing ceremony of the Rio 2016 Olympic Games.

Prime Minister Shinzo Abe, meeting Japanese athletes in Rio earlier on Sunday, said Tokyo now wanted to put on the best Olympics yet.

Dancers perform over the sign
Dancers perform over the sign "See you in Tokyo 2020" at the closing ceremony of the 2016 Rio Olympics.

"The Japanese government will strive hard so you can participate in the Tokyo 2020 Olympics so you will be in your best condition, and work hard so it will be the best Olympics ever," Abe told the Japanese athletes.

The good and the bad

United States' Michael Phelps swims during a men's 100-meter butterfly heat during the swimming competitions at the 2016 Summer Olympics, Thursday, Aug. 11, 2016
United States' Michael Phelps swims during a men's 100-meter butterfly heat during the swimming competitions at the 2016 Summer Olympics, Thursday, Aug. 11, 2016

Rio will be remembered for the comeback of American swimmer Michael Phelps, who won five golds and one silver to reinforce his distinction as the most decorated Olympian of all time.

Usain Bolt from Jamaica crosses the line to win the gold medal in the men's 200-meter final during the athletics competitions of the 2016 Summer Olympics at the Olympic stadium in Rio de Janeiro, Brazil, Thursday, Aug. 18, 2016.
Usain Bolt from Jamaica crosses the line to win the gold medal in the men's 200-meter final during the athletics competitions of the 2016 Summer Olympics at the Olympic stadium in Rio de Janeiro, Brazil, Thursday, Aug. 18, 2016.

Jamaica's Usain Bolt drew down the curtain on his brilliant Olympic career by securing a sweep of the sprint titles for a third successive Games.

United States' Simone Biles displays her gold medal for floor during the artistic gymnastics women's apparatus final at the 2016 Summer Olympics in Rio de Janeiro, Brazil, Tuesday, Aug. 16, 2016.
United States' Simone Biles displays her gold medal for floor during the artistic gymnastics women's apparatus final at the 2016 Summer Olympics in Rio de Janeiro, Brazil, Tuesday, Aug. 16, 2016.

And American gymnast Simone Biles, the US flag bearer in the closing ceremony, kicked off her Olympic run by tying the record of four gold medals in a single Games.

At times, it was hard to focus on the great sporting moments happening across the sprawling city.

A low point for Rio came when Ryan Lochte, one of America's most decorated swimmers, said he was robbed at gunpoint. That ignited further security concerns after a series of assaults against government ministers, athletes and tourists.

But Lochte's story quickly unravelled when police discovered he fabricated his story to cover up his vandalizing a gas station after a drunken night out with three teammates. His lie enraged Brazilians and Americans alike.

Brazilians could take heart in the fact that there were no major mishaps or breaches after deadly attacks in Europe and the United States had prompted the biggest security operation in Brazil's history. The military and police presence was extraordinary with 85,000 troops fanned out across venues, streets and transport hubs, double the deployment in London four years ago.

Source: TRTWorld and agencies