Barack Obama has urged Britain to stay in the EU, saying the world needed the UK's influence within Europe.
The US president, who has arrived in Britain for talks with David Cameron and lunch with the Queen, said membership of the European Union magnified the UK's status on the global stage.
But his intervention in the bitter EU referendum debate led to claims of hypocrisy from Brexit campaigners, who urged him to "butt out" of the UK's decision on June 23.
The president wrote in the Daily Telegraph: "As citizens of the United Kingdom take stock of their relationship with the EU, you should be proud that the EU has helped spread British values and practices - democracy, the rule of law, open markets - across the continent and to its periphery," he said.
"The European Union doesn't moderate British influence - it magnifies it. A strong Europe is not a threat to Britain's global leadership; it enhances Britain's global leadership.
"The United States sees how your powerful voice in Europe ensures that Europe takes a strong stance in the world, and keeps the EU open, outward looking, and closely linked to its allies on the other side of the Atlantic. So the US and the world need your outsized influence to continue - including within Europe."
The president said the deaths of tens of thousands of Americans in the battles to liberate Europe showed the strength of the ties between the US, UK and the continent.
"I will say, with the candour of a friend, that the outcome of your decision is a matter of deep interest to the United States," he said.
"The tens of thousands of Americans who rest in Europe's cemeteries are a silent testament to just how intertwined our prosperity and security truly are. And the path you choose now will echo in the prospects of today's generation of Americans as well."
Obama's much anticipated intervention comes as a boost to the Remain camp - but has infuriated senior figures in the Brexit movement.
The president said he realised there had been "considerable speculation - and some controversy - about the timing of my visit" but joked: "I confess: I do want to wish Her Majesty a happy birthday in person."
He said he realised there was a "spirited campaign under way here" and "ultimately, the question of whether or not the UK remains a part of the EU is a matter for British voters to decide for yourselves".
Brexit-backing London mayor Boris Johnson said Obama "would not dream" of involving the US in an organisation like the EU and accused him of being "downright hypocritical".
"This project is a million miles away from the Common Market that we signed up for in 1973," Johnson wrote in The Sun.
"It is deeply anti-democratic - and much as I admire the United States, and much as I respect the president, I believe he must admit that his country would not dream of embroiling itself in anything of the kind. The US guards its democracy with more hysterical jealousy than any other country on earth."
Ukip leader Nigel Farage said: "President Obama should butt out. This is an unwelcome interference from the most anti-British American president there has ever been. Mercifully, he won't be in office for much longer."
The Prime Minister, who will hold talks with Obama in Downing Street before a joint press conference, defended the president's right to speak out on the EU issue.
He told BBC Radio Bristol: "I do think it's good to listen to your allies and friends and America, who work with us so closely, who lost a lot of people in the First and Second World Wars fighting alongside the British, as we often do.
"I think he is perfectly entitled to say, 'as a friend of Britain, I'm not going to tell you what to do, I'm just going to tell you what I think'."