The closing ceremony, entitled "A Symphony of British Music", was a celebration of Britain's pop prowess, with Queen, Take That and the Spice Girls getting the Olympic Stadium rocking underneath a blaze of fireworks.
Thousands of athletes who have entertained the world during the London Games craned to take pictures of George Michael and Fatboy Slim performing at the centre of a giant stage in the shape of Britain's Union Jack flag.
Meanwhile the pumped-up 80,000-strong crowd got into the party atmosphere, singing along in full voice as waves of colour swept around the bowl on the pixel screens in front of each seat.
The Olympic flame was slowly extinguished with tangible sadness in the stadium, but the feeling lasted only seconds before legendary rockers The Who blasted the blues away with a final salvo of thunderous hard rock and dazzling pyrotechnics.
"After 16 days of competition, we wanted to host a celebration of all that's good about London, British people, our music and our culture," Kim Gavin, the show's artistic director, said beforehand.
More than 300 million people would be watching around the world, the audience were told.
The three-hour spectacle began with New Year-style Big Ben chimes counting down to 9:00pm (2000 GMT).
In his biggest role to date, 27-year-old Prince Harry, third in line to the throne, represented Queen Elizabeth II at the show.
1980s band Madness kicked off the mass singalong with their hit "Our House", before The Kinks' frontman Ray Davies then played his London love song "Waterloo Sunset" with the crowd on backing vocals.
While a chosen athlete carried each national flag into the stadium, the competitors streamed in as one, some wearing their medals and others taking souvenir pictures as they formed the wedges in the Union Jack.
There was one final well-respected medal ceremony -- that for Sunday's men's marathon, won by Uganda's Stephen Kiprotich.
A hallmark of the London Games has been the enthusiastic warmth shown to athletes regardless of nationality.
Annie Lennox appeared as the figurehead of a ghost galleon, while DJ Fatboy Slim performing on a psychadelic camper van that turned into a blow-up octopus.
Next the Spice Girls sang a medley of their hits while riding around the stadium on top of London black cabs, before Oasis star Liam Gallagher had the crowd waving their arms with the 1990s classic "Wonderwall".
After seemingly failing as a human cannonball, Monty Python comedian Eric Idle performed "Always Look on the Bright Side of Life".
The late Queen singer Freddie Mercury then appeared on the screens to conduct the crowd, before the band emerged, getting the stadium thumping to "We Will Rock You".
As the 2012 Games came to a close, London Mayor Boris Johnson handed over the Olympic flag to Eduardo Paes, the mayor of 2016 hosts Rio de Janeiro.
Led by football legend Pele, the Brazilian city then gave a taste of the carnival the world can expect in four years' time.
"When our time came -- Britain, we did it right," said London Games organiser Sebastian Coe. "The spirit of these Olympics will inspire a generation."
International Olympic Committee President Jacques Rogge added: "These were happy and glorious Games," before saying: "I declare the Games of the 30th Olympiad closed."
As a phoenix rose above the cauldron, which opened like a flower, Take That performed "Rule the World" beneath a cascade of fireworks.
It was finally extinguished with a sad "ah" from the crowd, before The Who rounded off the night.
Spectator Jonathan Mann, 51, said: "I have been absolutely blown away by the whole of the Olympics. The whole spirit of the country has been fantastic. It's been absolutely incredible."
What the stars mean:
★ Poor ★ ★ Promising ★★★ Good ★★★★ Very good ★★★★★ Exceptional