The London Olympics were declared closed as part of a spectacular ceremony that featured more than 4,000 performers alongside British rock groups such as The Who and the Spice Girls.
International Olympic Committee (IOC) president Jacques Rogge said: "These were happy and glorious Games." "Many young people will be inspired to take up a sport or to pursue their dreams."
The official Games flag was handed to the mayor of Rio, which will host the next Olympic Games in 2016, before the flame at the Olympic Stadium was extinguished.
The United States topped the final medal table with 104 medals, followed by China and then Great Britain.
In all, 44 world records have been set during London 2012.
Some will remember the 16 days of the London Games for the record-breaking exploits of U.S. swimmer Michael Phelps, who took his life-time medal haul to 22, including 18 golds, making him the most decorated Olympian in history.
There was also the Jamaican Usain Bolt, who defended the gold medals in the 100 and 200 meters and the 4x100 relay that he won in Beijing in 2008.
On the last day of sporting action, the Russians won Olympic gold medal in the group event of rhythmic gymnastics.
Russia, has won both rhythmic titles at every Olympics dating back to the Sydney Games in 2000, finished with 57 points, 1.5 points ahead of Belarus.
Kazakh boxer Serik Sapiyev defeated Britain's Freddie Evans by a score of 17-9 to win the gold medal in the men's welterweight division.
Ukraine's Vasyl Lomachenko defeated South Korea's Han Soonchul by 19-9 to take the gold medal in men's lightweight boxing.
Russia’s basketball team beat Argentina 81-77 to take the bronze medal.
In handball, Croatia beat Hungary 33-26 to take the bronze medal in the men's handball competition.