Legendary track star and chairman of the London Organizing Committee Sebastian Coe congratulated his fellow Britons for a "glorious" Olympic Games on Sunday night.
"When our time came, Britain, we did it right," Coe told the 80,000 gathered at Olympic Stadium for the closing ceremony.
Coe said these "two glorious weeks" would "inspire a generation."
International Olympic Committee President Jacques Rogge declared the London Games officially over.
He echoed Coe's sentiments.
"These were happy and glorious Games," he said. "The legacy of the Games of the 30th Olympiad will become clear in many ways. Concrete improvements in infrastructure will benefit the host nation for years to come. The human legacy will reach every region of the world. Many young people will be inspired to take up a sport or to pursue their dreams."
As the Games came to a close, the United States led the medal count with 104 overall, 46 of them gold.
China finished second, with 87 medals, with Russia third with 82. Great Britain finished with 65, its best total since 1908.
Singers from all eras performed. There was rock great Ray Davies, pop heroes George Michael and Annie Lennox, and new boy-band One Direction. Even comedian Russell Brand joined in, singing The Beatles "I Am The Walrus."
The crowd gave the Spice Girls a rousing ovation after they performed two of their hits.
Other performers payed tribute to some of the artists who didn't attend or had passed away.
Singers Jessie J and Taio Cruz teamed with rapper Tinie Tempah to sing "You Should Be Dancing" by the Bee Gees (born on Isle of Man). Ed Sheeran led a quartet with Pink Floyd drummer Nick Mason, Richard Jones of the Feeling and Mike Rutherford of Genesis in covering "Wish You Were Here."
Later Monty Python actor Eric Idle led the crowd in singing "Always Look on the Bright Side of Life."
To close the music medley Jessie J also joined Brian May and Roger Taylor of Queen, belting out "We Will Rock You."
The Who closed out the ceremony with a medley of the band's hits, ending with "My Generation."
In a new twist, the 10,000-plus athletes entered the stadium through the stands, some high-fiving members of the audience as they descended the steps to the field.
There was also one final medal ceremony as Stephen Kiprotich of Uganda was awarded his marathon gold and listened along with the spectators to his national anthem.
The White House released a statement that said President Obama called British Prime Minister David Cameron congratulating London on an "extremely successful" games.
One of the U.S. golds came as expected on the basketball court, but in a tougher contest than expected.
Led by Kevin Durant's 30 points, the United States fought off a stiff challenge from Spain to win the gold medal 107-100.
The Americans defended their title from four years ago in Beijing, also against Spain.
"This game was fun. It was a challenge, but we stepped up to it," Kobe Bryant told NBC, an official broadcaster of the Games.
LeBron James had 19 points and Bryant scored 17 for the Americans, who led by only one point after the third quarter.
"We all respect each other," Durant said. "We all know it's our common goal."
Russia narrowly edged out Argentina for the bronze.