A referendum on whether to remain in the EU will be held by the end of 2017 under David Cameron’s plans to renegotiate the terms of the UK’s membership before putting that new deal to the public.
Mr Obama said the UK’s membership of the EU gives “much greater confidence” about the relationship between the United States and Europe.
In a BBC interview, the president said he wanted to make sure the UK continued to have the “influence” that came with membership of the EU.
He said: “Having the United Kingdom in the European Union gives us much greater confidence about the state of the transatlantic union and is part of the cornerstone of the institutions built after World War Two that has made the world safer and more prosperous.
“We want to make sure that the United Kingdom continues to have that influence.”
It is the latest sign of the importance Washington places on the UK staying in the EU, after comments made by Mr Obama at the G7 summit of world leaders in Germany in June.
As he met Mr Cameron for talks at that summit, the president said that “one of the great values of having the United Kingdom in the European Union is its leadership and strength on a whole host of global challenges, so we very much are looking forward to the United Kingdom staying part of the European Union because we think its influence is positive not just for Europe, but also for the world”.
The US president welcomed Mr Cameron’s commitment to continue meeting the Nato target of spending 2% on defence.
He said: “We don’t have a more important partner than Great Britain. For him to make that commitment when he has a budget agenda that is confined, a budget envelope that is confined, is significant.”
The US administration has previously expressed concerns about the UK’s commitment to military spending and had pressed for Mr Cameron to commit to the target.
In June US defence secretary Ashton Carter said the UK had always “punched above its weight” militarily and it would be “a great loss to the world” if it cut defence spending in a way that suggested it was “disengaged”.
With 18 months left in office, Mr Obama expressed frustration at his inability to take action on gun control in the wake of a series of shootings in the USA.
“If you look at the number of Americans killed since 9/11 by terrorism, it’s less than 100. If you look at the number that have been killed by gun violence, it’s in the tens of thousands,” Mr Obama said.
“And for us not to be able to resolve that issue is distressing.”
A No10 source said: “As the Prime Minister said in June, it’s right for Britain to have this renegotiation and this referendum to address the concerns the British people have about Europe and to make sure the British people have the final say about whether we stay in a reformed European Union.”
For Labour, shadow foreign secretary Hilary Benn said Mr Obama’s comments showed how Britain’s partnership with the US was enhanced by membership of the EU.
“Labour is fighting to protect Britain’s interests by campaigning to remain in Europe while David Cameron’s weakness and indecision are putting our country’s future international influence and prosperity at risk.”