"The UK's EU membership gives us much greater confidence about the strength of the transatlantic union," he said.

Speaking to the BBC's North America editor Jon Sopel, he said the EU "made the world safer and more prosperous."

David Cameron has said a referendum on whether or not to remain a member of the EU will be held by the end of 2017.

That referendum will follow a renegotiation of the existing terms of British membership.

The prime minister has said he will campaign for Britain to remain in the EU if he gets the reforms he wants.

Obama said the UK was America's "best partner" because of its willingness to project power beyond its "immediate self-interests to make this a more orderly, safer world."

Obama described the UK's prime minister as an "outstanding partner" and congratulated his government for meeting the NATO target of spending 2% of the country's national income - GDP - on defense.

In his BBC interview, Obama denied putting pressure on Cameron to meet that target but said there had been an "honest conversation" between the two leaders.

The U.S. President, who has 18 months left in power, also admitted that the failure to pass "common sense gun safety laws" in the U.S. was his biggest frustration.

He was speaking to the BBC at the White House before departing for Kenya, where he begins a short tour of Africa on Friday.