United States of America topped the medals tally with 121 medals (46 Gold, 37 Silver, 38 Bronze), followed by Great Britain (27 23 17) and China (26 18 26).
Rio de Janeiro: Rains failed to dampen the famous Rio carnival spirit as this Brazilian city bid an emotional farewell to the thousands of athletes of the world in a colourful closing ceremony to bring down curtains on the 31st Olympic Games here.
International Olympic Committee President Thomas Bach declared the Games closed to mark the official end of the 16-day sporting spectacle competed among more than 11,000 athletes from 205 countries in 42 disciplines.
"I declare the Games of the 31st Olympiad closed. In accordance with tradition, I call upon the youth of the world to assemble in four years time in Tokyo, Japan to celebrate the Games of the 32nd Olympiad," Bach said to the huge applause of the packed gathering at the iconic Maracana Stadium on Sunday night.
This was after the Olympic flag was lowered and handed over to the representative of Tokyo 2020, the next host of the Games. Bach handed over the flag to female Governor of Tokyo Yuriko Koike.
Japanese Prime Minister Shinzo Abe made a dramatic entry in a high-tech show, a trademark of the far eastern country, during a short but impressive performance titled 'See You in Tokyo'.
The athletes braved harsh winter winds, accompanied by torrential showers, and enjoyed the festive atmosphere after intense competition in their respective events ended.
Torrential showers continued unabated but it did not matter to the athletes who sported translucent raincoats with several of them singing, dancing and taking selfies during the nearly three-hour-long closing ceremony.
The athletes entered the pitch with Greece coming first according to tradition.
Led by Sakshi Malik, the first Indian woman wrestler to win an Olympic medal whose bronze opened the medal count of two including a silver, the country's contingent also braved the rains as she stood tall waving the tri-colour.
The honour of bearing the Indian flag came to Sakshi as silver medalist shuttler P V Sindhu had left yesterday as about 50 Indians, including the men's and women's hockey teams, the wrestlers and boxer duo of Shiva Thapa and Manoj Kumar, participated in the athletes' parade.
India ended the Games at 67th position with one silver and a bronze. United States of America topped the medals tally with 121 medals (46 Gold, 37 Silver, 38 Bronze), followed by Great
Britain (27 23 17) and China (26 18 26). Host country Brazil were at 13th position with 7 Gold, 6 Silver and 6 Bronze.
A day after a frenzied Brazil celebrated its maiden gold in men's football with a win over Germany at the same iconic venue, the closing ceremony added colour and glitz and cheered the likes of Neymar and Usain Bolt when they were displayed on giant screen during a video of Rio 2016's defining moments.
Accompanied by fireworks, the countdown to the start of the 13-segment show honoured 'father of aviation' Santos Dumont, creator of first controllable aircraft with an engine as he announced the "party to begin".
Projections of watch gears were put on the field of play, signifying the countdown for the show.
Welcoming the spectators to the Maracana, a projection from the point of view of a bird flying over the host city of Rio de Janeiro was shown as the city's landmark points -- Christ the Reedemer, Sugarloaf -- were seen and it reached the climax with the formation of five Olympic rings.
Music took over the field as icon of Rio's samba Martinho da Silva, accompanied by his three daughters, dished out a soul-stirring performance of 'Carinhoso', one of the all-time Brazilian popular songs.
Brazilian National Anthem was then sung by 27 children, representing country's 26 states plus the Federal District, accompanied by a powerful percussion band, which was preceded by a tribute to some important songs and composers of Brazilian popular music.
The real heroes of the Summer Games, athletes from 207 delegations including the Refugee Olympic Team, entered the arena together sending out a message of communion and fellowship in the longest show of the closing ceremony spanning 47 minutes and 51 seconds.
Electronic music superstar Kygo and singer-song writer Julia Michaels took to the main stage and enlivened the end of the Athletes' Parade with the song 'Carry Me'.
The next segment celebrated Brazilian artists, which was followed by a two-minute feature on the defining moments of Rio, followed by the Games last medal ceremony -- the men's marathon.
11 minutes 45 minutes were dedicated to Tokyo 2020 as the Japanese expressed their gratitude and put up a display of grit, determination, courage and hope to make it a greater success in four years' time.
It was followed by the official protocol of speech giving before a carnival parade entertained the spectators. The spectacular fireworks display emanating from the Maracana lighted the Rio sky and Olympic flame was finally doused as it was time to bid goodbye and bring curtains down on the sporting spectacle.
But it was not before Brazil's signature samba carnival march that has become an anthem. Traditionally attired samba dance masters and flag bearers' entered the pitch after six singers began singing 'Cidade Maravilhosa.
To the sound of popular samba songs, Brazilian top model Izabel Goulart was joined by Renato Sorriso, a dustman and road sweeper who became famous for his good humour and smile while cleaning up after Carnival in 1997 in a unique gesture.
Bach thanked the volunteers, athletes and the Refugee Olympic Team who participated in the Games for the first time.
"You the athletes of the world have shown us all the power of sport to unite the world. Together, we can go further. Together, we can aim even higher. United in our diversity, we are stronger," Bach said.
"Thank you, dear refugee athletes. You have inspired us with your talent and human spirit. You are a symbol of hope to the millions of refugees in the world. We will continue to stay at your side after these Olympic Games.
"We arrived in Brazil as guests. Today we depart as your friends. You will have a place in our hearts forever," he added in an emotional speech.
Bach was accompanied by Carlos Arthur Nuzman, the president of the Rio 2016 Organising Committee.
"I'm the happiest man alive at the moment. Let's celebrate together the Games of Rio. It will stay forever," Nuzman said.
The IOC also honoured the people who made this 'miracle' happen by awarding the Cariocas (native of Rio) the Olympic Cup, which was constituted by the the founder of the modern Olympic Games, Pierre de Coubertin.
"The IOC has invited six of you to accept this Cup here tonight," Bach said.