The Summer Olympics came to a close in Beijing with a blast of fireworks, spectacular pageantry and athletes and spectators alike celebrating the joy of sport.
Tens of thousands of spectators and athletes packed what became known as the Bird's Nest, the Games' main stadium, for a final party and send-off on Sunday night.
"Tonight, we come to the end of 16 glorious days which we will cherish forever," IOC president Jacques Rogge told the crowd at the National Outdoor Stadium. "Through these Games, the world learned more about China, and China learned more about the world."
"These were truly exceptional Games," he said, and then declared them formally closed.
Liu Qi, the head of the Beijing organizing committee, said the Games were "testimony to the fact that the world has rested its trust in China."
When the first round of fireworks died down, a military band played the Chinese national anthem before thousands of acrobats and drummers in brightly coloured costumes danced onto the field.
Unlike the Aug. 8 opening ceremonies, when athletes arrive in groups with their country-mates, the Olympians ran into the stadium, waving to spectators and snapping pictures.
Members of the Canadian team climbed onto each other's shoulders as flags fluttered from their backs. Some bumped into Chinese basketball star Yao Ming and crowded around him for a snapshot.
Led Zeppelin guitarist Jimmy Page and British songstress Leona Lewis represented the host of the 2012 Summer Games, London, with a concert from a stage rigged from a double-decker bus. Soccer star David Beckham also appeared.
The ceremonies were also highlighted by a kung-fu demonstration by athletes from a local martial arts school and a duet sung by Chinese soprano Song Zuying and tenor Placido Domingo.
Games 'cannot force changes'
China spent about US$40 billion to produce an Olympics that ran like a well-oiled machine but still generated controversy.
The Chinese government put a tight lid on free speech, deporting protesters who sought to highlight human right's issues in Tibet and even blocking the international media from viewing certain websites.
Throughout the Games, Rogge defended the organization's decision to award China the Olympics and continued to do so.
"The IOC and the Olympic Games cannot force changes on sovereign nations or solve all the ills of the world," Rogge said earlier. "But we can -- and we do -- contribute to positive change through sport."
Chinese athletes put their country at the top of the gold medal tally with 51. China's 99 total medals was the country's best showing ever at an Olympics.
The United States won the most medals, with 108. Canada finished with 18.
Sports lovers got quite the show, as the sixteen days of competition produced 43 world records and 132 Olympic records.
Highlights included Michael Phelps's eight gold medals in swimming and Jamaica's Usain Bolt and his three golds in track and field.
Canadian medal haul
After a slow start by Canadian athletes, the Games marked Canada's third-best showing at a Summer Olympics. The final medal tally is three gold, nine silver and six bronze medals.
Canada's first gold medal was won by Hazelton, B.C.'s Carol Huynh, who came out on top of the women's freestyle 48 kg wrestling competition.
Other Canadian highlights included 61-year-old show jumper Ian Millar capturing a silver medal - his first - in the equestrian team event. Miller had participated in every Olympics since 1971 and the Beijing Games marked his ninth trip to the big show.
Millar dedicated the victory to his late wife, Lynn, who died of cancer in March.
Millar's teammate, Schomberg, Ont.'s Eric Lamaze, became the first Canadian ever to win a gold medal in the individual equestrian event. Lamaze's win marked his comeback after missing the last two Olympics due to positive cocaine tests.
Canada's flag-bearer at the opening ceremonies, kayaker Adam van Koeverden, overcame a disappointing eighth-place finish in the K-1 1,000 metre race with a silver medal in the 500 metres.
Canadian athletes also posted 12 fourth-place finishes throughout the Games.
With files from The Associated Press