By Roberta Rampton and Kylie MacLellan

LONDON (Reuters) - President Barack Obama made a bold intervention into the politics of Washington's closest ally on Friday, exhorting Britons to stay in the EU and warning that if they left they would be at "the back of the queue" for a U.S. trade deal.

Obama's plea to British voters ahead of a June referendum on membership of the European Union was welcomed by Prime Minister David Cameron and other supporters of the EU, but denounced by those campaigning to leave as meddling in British affairs.

Britain's influence on the world stage was "magnified" by its membership of the 28-member bloc, Obama said at a press conference alongside Cameron, who has bet his political future by calling the referendum to put to rest an issue that has divided his own Conservative Party for generations.

Rebutting criticism that he was interfering, Obama invoked the cherished "special relationship" between Washington and London.

"If one of our best friends is in an organisation that enhances their influence and enhances their power and enhances their economy, then I want them to stay in it," Obama said. "Or at least I want to be able to tell them: 'I think this makes you guys bigger players.'"

On trade, he took aim at one of the main "Out" arguments -- that Britain could easily negotiate deals and get better terms on its own. The United States would regard a deal with the EU as a higher priority than a separate agreement with a much smaller market such as a stand-alone Britain, Obama said.

"It's fair to say that maybe some point down the line there might be a UK-US trade agreement but that's not going to happen anytime soon because our focus is negotiating with a big bloc, the European Union, to get a trade agreement done," Obama said.

"And the UK is going to be in the back of the queue, not because we don't have a special relationship but because given the heavy lift on any trade agreement, us having access to a big market with a lot of countries rather than trying to do piecemeal trade agreements is hugely efficient."

Cameron said Britain should listen to its friends, and he could not think of any close ally who wanted a Brexit.

Obama set out his case in a newspaper article that invoked the interlinked history of the United States and Britain and the tens of thousands of Americans lying in European war graves.

"As your friend, I tell you that the EU makes Britain even greater," the headline read.

"Together, the United States, the United Kingdom, and the European Union have turned centuries of war in Europe into decades of peace, and worked as one to make this world a safer, better place," Obama wrote.

"DOWNRIGHT HYPOCRITICAL"

But those campaigning for an "Out" vote in the June 23 referendum were dismissive.

London's New York-born Mayor Boris Johnson, a leader of the "Out" campaign from within the Conservative Party widely seen as angling for Cameron's job, said Obama's advice was "incoherent, inconsistent and downright hypocritical".

Obama was urging Britain to pool its sovereignty with other nations in a way that the United States would never countenance for itself, Johnson wrote in a newspaper column.

He also referred to "the part-Kenyan President's ancestral dislike of the British empire", a comment widely criticised as demeaning the EU debate, and even denounced as "dog-whistle racism" by an opposition Labour politician.

Other "Out" campaigners said Obama's views did not matter because this is his last year in office.

"Obama doesn't have the authority to deny us a (trade) deal, as he will be long gone before any such proposals are on the table," said Richard Tice, co-founder of Leave.EU, one of several "Out" campaigns.

Experts struggled to find a precedent for Obama's direct appeal to British voters.

"It is the biggest intervention I can think of by an American president who has turned up in this way and intervened directly in the politics of a Western democracy since the end of the Cold War," said Anand Menon, professor of European politics and foreign affairs at Kings College London.

"It is above and beyond what people do in Western democracies. And if you think as I do that it is a fear thing, then it works."

Opinion polls suggest that "In" is ahead, but the race is tight and the number of undecided voters is very high.

Story continues