Hillary Clinton has thrown her weight behind the campaign to keep Britain inside the European Union in a major new boost to David Cameron’s hopes of winning a Remain vote on 23 June.

After Barack Obama used his farewell trip to the UK as president to make the economic and security arguments for membership, Clinton, who is the favourite to win the Democratic nomination in July and become the first female US president, makes clear that if she enters the White House she will want the UK to be fully engaged, and leading the debate, within the EU.

In a statement to the Observer, her senior policy adviser, Jake Sullivan, said: “Hillary Clinton believes that transatlantic cooperation is essential, and that cooperation is strongest when Europe is united. She has always valued a strong United Kingdom in a strong EU. And she values a strong British voice in the EU.” Sources close to the former secretary of state’s campaign said she stood fully behind Obama’s opposition to Brexit, which the president said on Friday would not only undermine the international institutions, including the EU, that had bound nations closer together since 1945, but would also mean the UK being at “the back of the queue” when negotiating new trade deals.

Obama’s remarks drew angry responses from leading figures in the Leave campaign, including the mayor of London, Boris Johnson, who questioned the president’s right to intervene. Leading backers of Brexit also tried to dismiss Obama’s view as that of a “lame duck president” soon to be out of office.

The former Tory defence secretary Liam Fox, a Brexit enthusiast, said on Friday night that Obama’s opinions would be irrelevant after the US elections in November. “Whoever it is that will be at the helm of the United States won’t be Barack Obama,” Fox told BBC2’s Newsnight. “It will be the next president, and the next congress, who will be in charge of any trade arrangements.” But the Remain camp and No 10 sources said that such arguments had exploded in the faces of the Brexit camp.

The Conservative MP Damian Green, a board member of the Britain Stronger In Europe campaign and the chairman of European Mainstream, said: “This shows how misleading it is to say this is just the view of a president in his last days in office. It confirms that mainstream political opinion in the United States is in favour of Britain remaining in the EU, and that the transatlantic values that we share with the US are expressed most strongly in Europe by a fully engaged Britain.”

A No 10 source said: “Not only do you have the serving US president setting out why the UK is better off staying in the EU, but now those who aspire to be president too. Hillary Clinton worked with the UK as secretary of state for a number of years and saw first hand how the UK’s influence was magnified by the role we played in the EU. When you face a big decision in life, most people listen to their friends, and we disregard such advice at our peril.”

The Republican presidential hopeful Donald Trump has not offered a view on whether he thinks the UK should stay in or leave the EU, although he has said he believes there is a good chance the British people will vote for Brexit, partly because of their unhappiness with levels of immigration.

Barack Obama has also urged British voters to vote to remain. Photograph: Christopher Furlong/Getty Images

The Labour leader, Jeremy Corbyn, a lifelong critic of American foreign policy, held talks with Obama during which the president congratulated him on being elected leader and the two touched briefly on Europe. Corbyn said they discussed “the challenges facing post-industrial societies and the power of global corporations and the increasing use of technology around the world and the effect that has”.

Earlier, addressing an audience of 500 people, many aged between 18 and 30, at a town hall-style event in central London, the president said that the UK’s role in the EU had helped secure peace on the continent.

The president said that “from the ashes of war” the UK and the US had formed institutions that had delivered “decades of relative peace and prosperity in Europe and that in turn have helped spread peace and prosperity around the world”.

Obama urged the young audience to reject isolationism and xenophobia. “I implore you to reject those calls and I’m here to ask you to reject the notions and take a longer and more optimistic view of history,” the president said.

Obama leaves the UK on Sunday for Germany, where he will attend Hanover’s industrial technology fair. He will then hold talks with David Cameron, the French president, François Hollande, German chancellor Angela Merkel, and Matteo Renzi, the Italian prime minister, during which they will discuss the next phase of the war against Islamic State and the unfolding chaos in Libya.