The XXX Olympiad ended Sunday with a blowout of British pop and circumstance, a closing-ceremony-cum-after-party offering a final dose of eccentricity to 17 days that saw the rise of girl power in sports, the coupling of Olympic solemnity with English humor and a wave of euphoria in a host nation that seemed to rediscover the “great” in Great Britain.

Like the Who and the Spice Girls on Sunday, Britons reunited over the course of these Games, showing the kind of feverish patriotism infrequently seen on this side of the Atlantic.

Big Ben chimed to mark the beginning of the end inside the Olympic Stadium, where the wonderwall of music included a virtual Freddie Mercury and a jolly postscript echoing Monty Python: “Always Look on the Bright Side of Life.” Four years after the militant efficiency of Beijing 2008, George Michael crooned “Freedom 90,” an impromptu anthem for the irreverent London Games. “We Will Rock You,” the British promised. And with surprisingly few major gaffes, they did.

The group Madness sang “Our House,” and that’s what these Olympics were. Britain threw a party for the world, but, first and foremost, for itself.

The Games were strewn with references to Britishness, some obscure and some not — organizers crammed the world’s athletes onto a stage cut in the form of a Union Jack at the Closing Ceremonies. If we had a good time, it was because we were along for the ride.

Urged on by massive home crowds and a cheerleading press that defied predictions of Olympic cynicism, British athletes ran, cycled and rowed their way to their highest medal count since Britannia ruled the seas in 1908.

At these Games, the United States and China might be coming home with more gold, but this country of 62 million people that is roughly the size of Michigan reminded itself of its uncanny ability to punch above its weight.

The Sunday Telegraph proudly challenged, “Who thinks Britain is rubbish now?”

Though the British may wake up with an Olympic-spirit hangover Monday and remember their famously naysayer reserve, two weeks of infectious excitement seemed to spread optimism across a land mired in recession and still scarred from the urban riots that rocked London this time last year.

For now, those images have been replaced by those of Britain’s giddy 18-year-old diver Tom Daley celebrating like a frat boy after winning a mere bronze, immigrant runner Mo Farah in shock after his second gold, and the beautiful smile of this nation’s own million-dollar baby, Nicola Adams, who entered the record books as one of the first female boxers to top the medal stand in a sport that only this year let women compete.

In a country with an uncomfortable relationship with aspiration, where the successful are often seen as overly earnest sellouts, the inspiration of the moment may indeed fade fast, many here concede. The choices of aging rock stars and a homage to London of decades gone by as the headlining themes Sunday also suggested less a look forward than a certain clinging to Britain’s past. But like the doses of British beet juice that have become the energy drink of choice among so many Olympians, the London Games have seemed to be nothing if not a $15 billion national pick-me-up.

“Over the last couple of weeks we have looked in the mirror, and we like what we have seen as a country,” Prime Minister David Cameron told reporters Sunday after vowing to protect the $200 million a year earmarked for British Olympic athletes. He added: “Take all of this, the attitude, the confidence, and you see what Britain is today — sure of who we are, proud of who we are. In short, not a country whose time has been but whose time has come.”

Despite the impression sometimes given by the BBC’s domestic coverage, these were not Britain’s Games alone.

Michael Phelps reaffirmed his status as the greatest swimmer of all time in the face of rival Ryan Lochte. New stars, such as American Missy Franklin, were born. Old stars, such as Usain Bolt, went supernova, with the Jamaican runner establishing himself as the greatest sprinter ever, a joy of life virtually exploding from his taut body as he played the superhero after winning his golds.

Women made up 44 percent of competitors at these games, the highest of all time, including the first-ever female athletes from Saudi Arabia, Qatar and Brunei. American women — including those who won the soccer final against Japan that marked the NBC Sports Network’s highest ratings ever — took home 29 gold medals, compared with their countrymen’s 17. And the women of 2012 also brushed aside the rude missives that have marked the age of Twitter, such as those aimed at gymnast Gabby Douglas’s hair.

“It doesn’t matter how we look — we just won the gold medal,” said Kayla Harrison, the gold medalist in judo for the United States. “It doesn’t matter what we wear — we’re part of Team USA, and there’s no better color than the American flag.”

Montenegro won its first Olympic medal. The United States won its 2,757th. There were Olympic rivalries, friendly and otherwise. The Danes hurled the insult “Furniture makers!” at the Swedes, a reference to the fine wares at Ikea. The U.S. basketball team traded (alleged) punches with Argentina’s squad.

As Olympic host cities are wont to do, London already seemed to be developing a rivalry with Rio de Janeiro, host of the 2016 Games. Brazil, in a music smack-down it almost won, foreshadowed a tropical carnival of sport and samba during its rousing handoff spot Sunday night. Britain’s Observer newspaper on Sunday declared there could be “shadows in the sunshine,” citing worries over “building delays, bribery and a hidden underworld” in the South American nation.

Rio’s mayor, Eduardo Paes, said in an interview that he had politely declined eccentric London Mayor Boris Johnson’s suggestion of pulling off something slightly more insane for the Olympic handoff. Nevertheless, he played the rivalry game to a T.

“Of course ours will be the best Games ever,” he said. “Come on. They’ll be in Rio. So what else could they be?”

Karla Adam contributed to this report.