LONDON — Even for an American president, the extravagant scene at Buckingham Palace could seem surreal.

For two nights, President Barack Obama is calling this 775-room palace home, sleeping in the same suite where Prince William and wife Catherine spent their wedding night, dressing in white tie and tails for only the second state dinner for a U.S. president and receiving a toast from Queen Elizabeth in front of royalty and movie stars.

By definition, presidents run in the most rarefied circles. But even for White House veterans, Buckingham Palace is a whole different realm.

From the moment they arrived on palace grounds Tuesday morning, the president and first lady Michelle Obama stepped into a ceremonial whirlwind. It started with a 41-gun salute and an inspection of the Scots Guards at a welcome ceremony and culminated late at night with a cinematic dinner scene: a royal throne, gold-trimmed china, sparkling tiaras, white gloves and 5-foot-tall flower arrangements that scented the cavernous ballroom.

“As we confront the challenges of the 21st century together,” Obama said in his return toast, “we can have confidence in the partnership that our two countries share based on the rock-solid foundation built during Queen Elizabeth’s lifetime and her extraordinary service to her nation and the world.”

There was one faux pas. As Obama began wrapping up his toast, he paused and said, “To her majesty, the queen” — a phrase that prompted the band to play “God Save the Queen,” even though he wasn’t finished. But Obama kept talking over the British national anthem.

The elaborate scene offered a stark contrast to the dominant story back home, the devastation in Missouri from a violent string of tornadoes. Obama started his day by announcing plans to visit the stricken areas Sunday, only hours after he returns from his six-day European tour, and he reiterated his commitment to provide federal support.

The president appeared to soak in the splendor of London calmly, his exuberance from Ireland a day earlier toned down ever so slightly for the more staid occasion.

At the welcome ceremony, he chatted with the colonel guiding him through a formal inspection of the Scots Guards. On a tour of the palace gallery, he chuckled along with the queen at a letter from her mother about a 1939 White House visit during which she was served hot dogs.

At the state dinner, top White House officials rubbed shoulders with royalty. Senior adviser David Plouffe sat next to the Countess of Wessex and former Prime Minister Gordon Brown. Actor Kevin Spacey was one place setting away.

Plouffe even got a spot in the royal procession — one of only five Americans other than the Obamas to do so. He joined a group that included Secretary of State Hillary Clinton, who was spotted earlier on a private tour of palace artwork.

Obama sat at the head table next to Queen Elizabeth and Camilla Parker Bowles. Michelle Obama, dressed in white gloves and a white gown from American designer Tom Ford, was flanked by Prince Philip and Prince Charles.

“Today, the United States remains our most important ally,” Queen Elizabeth said in her toast, “and our two nations contribute to the security and prosperity of our peoples, and of the world, through shared national interests.”

The queen, who met the Obamas and their daughters in 2009, has been intimately involved in planning, said a palace spokesman. Former President George W. Bush traveled to the palace in 2003 for the first state visit.

Obama balanced the pageantry of the palace visit with a short trip to a school with Prime Minister David Cameron, where both leaders let loose a bit.

They have big issues to confront — such as a debt crisis in their respective countries. But for a brief moment, they put all that aside for a game of table tennis.

“Who wants to take me on?” Obama asked as he walked into the Globe Academy school gymnasium, his jacket off and sleeves rolled up.

He and Cameron launched into a brisk match of two-on-two: the world leaders vs. the students.

The president’s competitive streak emerged quickly — he sighed when they missed points, high-fived when they scored, ribbed Cameron for playing with one hand in his pocket and made excuses when the ball fell just short of the table.

They didn’t keep score, but the battle with the students was one the world leaders appeared to lose.

Before the game, Obama visited a classroom with design projects, including one the students called Dish Dash — a carryout box that folds into a bowl or plate and then back again.

A teacher suggested that they needed an investor and offered up a British name. Obama had a different idea.

“Or Donald Trump in the U.S.,” Obama said, gesturing with his two fingers to indicate he and his almost-presidential-rival see eye to eye. “I have a connection with him.”