US President Barack Obama has been accused of doing Downing Street's bidding - after he said the UK would be at "the back of the queue" for American trade deals if it left the EU.

Mr Obama was criticised by pro-Brexit campaigners after he warned of the consequences of the UK leaving the EU.

UKIP's Nigel Farage said Mr Obama was "talking down Britain", while Tory Liam Fox said his views were "irrelevant".

Mr Obama, on a three-day UK visit, will meet Labour leader Jeremy Corbyn later.

In a speech in London, the US president urged young people to "reject pessimism and cynicism" and to "know that progress is possible and our problems can be solved".

"Progress is not inevitable," he said and must be fought for. "Take a longer, more optimistic view of history."

Mr Obama's intervention on the EU issue came on his first full day in the UK and comes just weeks ahead of the 23 June in-out referendum.

Speaking at a joint news conference with Prime Minister David Cameron on Friday, Mr Obama said the US "wants Britain's influence to grow - including within Europe".

"The UK is at its best when it's helping to lead a strong European Union. It leverages UK power to be part of the EU.

"I don't think the EU moderates British influence in the world, it magnifies it."

Image copyright Kensington Palace Image caption Prince George, who was dressed in his pyjamas and slippers, stayed up to meet Mr and Mrs Obama at Kensington Palace on Friday evening

Image copyright PA Image caption The young prince gave his parents' dinner guests a demonstration of his riding skills

Image copyright Reuters Image caption Prince Harry joined the two couples for the evening

BBC political correspondent Iain Watson said Mr Obama's message on trade was "very blunt" and "really upped the ante" in the referendum debate.

Leave campaigner Mr Farage drew attention to the US president's terminology, saying his use of the phrase "back of the queue" rather than the more common American vernacular "back of the line" suggested Mr Obama was doing the prime minister's "bidding".

"I think that's shameful," he added.

Mr Fox said Mr Obama would be leaving the White House soon, and therefore his comments were "largely irrelevant".

New markets

Conservative MP Dominic Raab labelled Mr Obama a "lame-duck American president doing an old British friend a political favour".

Downing Street rejected suggestions that any lines had been fed to Mr Obama, saying the US president spoke for himself.

Sir Andrew Cahn, a former chief executive of UK Trade & Investment, told BBC Radio 4's Today programme that Britain would "miss out on something very important and valuable" if it left the EU and was not part of a proposed trade deal between the bloc and the US.

Former foreign secretary Lord Owen said "Britain needs to create new markets away from the EU".

Media playback is unsupported on your device Media caption London Mayor Boris Johnson has said that he finds the US's "lectures" on EU referendum "paradoxical [and] very odd"

Meanwhile, another prominent Leave campaigner - former cabinet minister Iain Duncan Smith - has tried to move the referendum debate on to immigration.

In an article in the Daily Mail, he says the introduction of a national living wage - a move he supported while in government - will "surely lead to another stampede to our borders".

He adds: "To make the Living Wage work for British people, we need to be able to control the number of people coming in."

Image caption Mr Obama (far left) watched actors at the Globe perform scenes from Hamlet

Earlier on Saturday, Mr Obama visited the Globe Theatre, where celebrations marking the 400th anniversary of Shakespeare's death are taking place.

He watched actors perform several scenes from Hamlet, later joining them on stage.

"That was wonderful. I didn't want it to stop," he said.

Later, he will hold talks with Labour leader Mr Corbyn.

EU referendum: In depth

Image copyright Reuters

The UK's EU vote: All you need to know

EU for beginners: A guide

Is Britain safer in or out of the EU?

A-Z guide to EU-speak

Who's who: The Vote Leave team

Who's who: The Remain campaign