After a fortnight showcasing the best athletes from around the world, it was time to say goodbye to Rio as the 31st Olympic Games drew to a close.

In the spirit of Brazil it was always going to be the biggest party the world has ever seen, and gale force winds and driving rain were not going to dampen the celebratory mood as the Olympic winners and losers gathered at the Maracana Stadium.

The ceremony flag bearers were led out by Greek gold medallist, Ekaterini Stefanidi. With the flags of every participating nation raised, the athletes danced their way along the procession, brandishing their coveted medals as they stopped to take the obligatory selfie to capture the historic moment.

Dressed in colourful costumes, the dancers performed in the downpour undeterred to the sound of the samba, as a global viewing audience of millions watched. Team GB made sure they stood out from the crowd in some fancy, glow in the dark footwear.

Rio Closing Ceremony
Team GB inside the Maracana stadium during the closing ceremony of the Rio 2016 Olympic Games on Sunday, 21 August, 2016. Getty Images

Taking to Twitter, the athletes, press and special guests shared their final memories of Rio with group photos of teams and messages of congratulations for the competitors.

Canadian PM Justin Trudeau tweeted a message to the Canadian contingent saying: "An unforgettable #Olympics for Canada's athletes. Congratulations & thanks to all who competed for our country."

Despite being plagued by organisational problems, questionable presenters, tragic accidents and a reporter struck down with malaria amid concerns over the zika virus, the Rio Olympics has been hailed as a success for its support in celebration of global sport and sportsmanship.

The baton will now be handed over to Tokyo, as it prepares for its role of hosting the next Olympic Games in 2020.