David Cameron was subjected to a bizarre quiz on British culture and history as he appeared on one of the USA's most influential TV chat shows.
The prime minister was welcomed on to the Late Show by host David Letterman to the tune of the house band playing Rule Britannia and dry ice pumping into the studio to replicate a London fog.
And after a brief foray into the issues surrounding Syria and the Arab Spring - the subject of his speech to the United Nations earlier in the day - Letterman confronted him with a truly tough question - who composed Rule Britannia?
Cameron told Letterman: I've ended my career on your show tonight
A floundering Cameron made a guess at Edward Elgar, only to learn from Letterman's researchers that it was in fact the little-known Thomas Arne, setting words by James Thomson to music.
When he was told the identity of the composer of Rule Britannia, he joked: "That's bad, I've ended my career on your show tonight."
At times in the 15-minute interview, Cameron appeared baffled by Letterman's line of questioning, described as a joke UK citizenship test.
He also admitted to being stumped when asked for the English translation of Magna Carta - Great Charter - and hesitated a while before naming Runnymede as the location of its signing.
But he immediately named 1215 as the date it was drawn up and was able to give an account of its importance in the birth of democracy.
Much of Letterman's questioning appeared designed as an idiot's guide to Britain for American viewers, as he asked Cameron to name the four nations of the UK. "What is the deal on Wales?" asked Letterman. "Did they vote for you, the people of Wales?" "Some of them did," replied Cameron - and explain the difference between Northern Ireland and the Republic.
The prime minister was in New York to speak at the UN
Despite the gaffes, the reception for the prime minister was warm, with ITV news reporting most audience members rated him 10/10 as a guest.
Cameron had said he would use the show to "bang the drum" for Britain, and raised applause from the audience when he hailed the successful hosting of the Olympics and Paralympics this summer.
But he, perhaps diplomatically, ignored an apparent dig by Letterman at Republican presidential candidate Mitt Romney, who famously questioned if London was ready for the Olympics.
"The idea that two major world class athletics events took place in London... who would have bet against that going off flawlessly, as it seems to have done?" joked Letterman.
Cameron also boasted of his government's efforts to create a good environment for investment in the UK and about the creation of one million private sector jobs over the past two years.
But he admitted that he was "not very popular at the moment" - blaming his low ratings on the austerity policies needed to cut the deficit.
Cameron had to correct Letterman when he talked about "the British empire" - "it's not an empire, it's the United Kingdom", interrupted the PM - and when the host suggested Northern Ireland was "part of England.
The PM raised a laugh from the studio audience for the CBS show as he joked about Britain's historic relations with the US.
"There were some good bits and some less than good bits, and obviously we had a bit of a falling out," he said.
"I like to think we've got over that now."
In an indication of his determination to forge good relations with the victor of the upcoming presidential elections, he said: "I have got on well with Republicans, I can get on well with Democrats."
The loudest applause of the evening came when he revealed that Britain does not allow political advertising on TV - a major issue in the US as both Romney and Barack Obama have spent lavishly on attack ads in a multi-billion dollar presidential campaign.
But he revealed that it was thanks to TV that he was first recognised in the USA, when he was walking in the streets of New York and spotted by a passer-by who shouted: "Hey! Prime Minister's Questions! We love your show!"
Cameron is the first sitting British prime minister to join Letterman in the Ed Sullivan Theatre on Broadway - venue for the Beatles' first US TV performance in 1964 - though Tony Blair has appeared twice on the show since leaving office.
It is understood that the PM's team approached the Late Show to let them know Cameron would be available during his visit to New York for the United Nations General Assembly.
They were aware that they could be taking a risk in putting the Prime Minister up against the irreverent Letterman, who is known for off-the-wall questions - asking recent guest Boris Johnson if he cut his own hair.
The long-running Late Show has a daily audience of around three million with a mix of showbiz stars, humour and hard-hitting political interviews which regularly set the news agenda. Last week President Barack Obama used the show to issue his response to election rival Mitt Romney's claim that 47% of US voters saw themselves as victims.
Also on last night's British-themed edition were Trainspotting actor Jonny Lee Miller - now starring in CBS series Elementary, a US version of Sherlock Holmes - and folk-rock band Mumford & Sons.
Explaining the decision for the PM to appear with Letterman, one British government source said: "It is just a good opportunity. Britain has had an extraordinary year with the Jubilee, with the Olympics and with the Paralympics. We have got something good to shout about.
"So getting out there talking up Britain is important. We should never forget that we are the biggest investor in America, America is the biggest investor in us.
"There is a saying in business that when you want to do better you go back to your biggest customers and try and squeeze out a bit more."
Cameron defended the UK's decision not to join the euro, telling Letterman: "I think it's very important we keep our own currency... I think in Europe, if you've got a single currency, you are going to end up effectively with some form of single government. I don't want that for Britain.
"We are part of Europe, we trade, we co-operate, we work together. But I don't want to be part of a country called Europe. I want to be part of a country called Great Britain."
He compared the fiscal union proposed to make the euro work more effectively with the position of states like Texas and Nebraska which operate within the fiscal arrangements of a single country, the USA.
Warm welcome: David Cameron was the first UK PM on Letterman
Cameron he got a very warm reception when he mentioned the London Olympics, which had clearly gone down well with the studio audience.
"We think we put on a good show," said the Prime Minister. "We are incredibly proud of what happened."
He sidestepped a question about the ever-divisive US issue of gun control, saying that while Britain had tough laws on firearm ownership, "we have to respect each other's political traditions".
Letterman asked him: "I'm told you have three viable political parties... but all of them tend to be to the left of everything that might line up here in the US."
Cameron replied: "In a way, but it's pretty different traditions and cultures."
The Prime Minister will be visiting Brazil on Thursday on a trip to boost UK trade links with one of the world's fastest growing economies.