U.S. President Barack Obama at Buckingham Palace on Tuesday. (Lewis Whyld/AP)

President Obama finished his state visit to Britain Wednesday with a glittering dinner for Queen Elizabeth in London — and, thankfully, no more awkward toasts. His diplomatic gaffe the night before made headlines, even though it wasn’t clear how the heck it happened. A breakdown:

The setup: The president was finishing his remarks at Tuesday’s dinner at Buckingham Palace when he set down his note cards and picked up his glass. “Ladies and gentlemen, please stand with me and raise your glasses as I propose a toast: To Her Majesty the Queen, . . 

The screwup: At this point, the band launched into “God Save the Queen” — but Obama continued speaking over the music: “. . . for the vitality of the special relationship between our peoples, and in the words of Shakespeare, ‘To this blessed plot, this Earth, this realm, this England.’ To the Queen.” She gave him a look, he set down his glass, and then stood motionless until the music stopped. Then everyone picked up their glasses. Oops.

The President and First Lady at the Winfield House on Wednesday. (Jewel Samad/ Getty Images)

Contributing factors: Awkward wording of the toast, Obama’s decision to forge ahead gamely instead of. . .knowing when to quit.

The president made light of the incident, telling British Deputy Prime Minister Nick Clegg Wednesday, “I thought that it was like, it was like out of the movies when the soundtrack kinda comes in.” “I thought you did exactly the right thing,” Clegg assured him.

The British tabloids, usually quick to point out a protocol breach, appeared smitten by the Obamas and made little mention of the gaffe. The State Department declined to comment; a spokesman for the British Embassy said this “really isn’t an issue — by all accounts, it was a very enjoyable evening.”

See a video of the President’s toast here.