Mr Obama, who is on a three-day visit with his wife Michelle, is meeting PM David Cameron for talks.
Mr Obama has told the Daily Telegraph being in the EU magnified Britain's influence across the world.
But London Mayor Boris Johnson called his view "hypocritical", describing the EU system as "alien" to US traditions.
Prime Minister David Cameron is hosting Mr Obama at Downing Street.
The leaders are holding talks on the fight against so-called Islamic State (IS) and will later be joined by the UK's home, foreign and defence secretaries, and the chancellor.
Mr Cameron and Mr Obama are expected to discuss the progress being made in combating IS in Iraq and what more can be done to tackle the group in Syria.
The situation in Libya, where the West is considering how to support the newly-established Government of National Accord (GNA) in the battle against IS, will also be discussed.
The pair will later hold a joint press conference.
Earlier the president and First Lady Michelle Obama attended a private lunch with the Queen and Duke of Edinburgh at Windsor Castle - the day after the Queen's 90th birthday celebrations.
The Obamas brought the Queen a photo album of her many visits with US presidents and first ladies.
The album begins with her visit to the United States in 1951.
Then known as Princess Elizabeth, Duchess of Edinburgh, she toured George Washington's Mount Vernon Estate and met with President Harry Truman at the White House.
The Duke and Duchess of Cambridge and Prince Harry will welcome the Obamas for dinner at Kensington Palace on Friday evening.
BBC deputy royal correspondent Sarah Campbell
The Duke of Edinburgh drove the Queen into the Castle grounds to meet the president and first lady as they disembarked from their helicopter.
After a quick chat, there was some discussion over where people should sit, with Mr Obama opting for the front seat.
Prince Philip, aged 94, returned to the wheel.
This is the third time the couples have met and the first time in the historic surrounds of Windsor Castle.
Their last meeting was during a visit in 2011 when the Obamas stayed in Buckingham Palace.
In 2009, in what was taken to be a sign of a friendly relationship between the families, the first lady was photographed with her arm around the Queen's waist.
In their meetings since, including today, there does seem to be a genuine warmth between the two families.
Today's lunch is private. To the frustration of the many journalists covering this visit, whatever the Queen makes of the president's views on Britain in Europe will remain within the castle walls.
The president's intervention in the UK's forthcoming EU referendum on 23 June has been hotly debated and sparked claims of "hypocrisy" from those who want to leave the EU. They claim the US "would never contemplate anything like the EU for itself".
In an article for the newspaper, President Obama acknowledged that ultimately the matter was for British voters to decide for themselves.
But he also said: "The outcome of your decision is a matter of deep interest to the United States.
"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."
In response, Mr Cameron tweeted: "The US is one of our closest allies. So it's important to hear Barack Obama on why we should remain in the EU."
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
BBC North America editor John Sopel said the president had not needed to make his intervention and could have been much more nuanced.
"That he has is a mark of the profound concern felt in Washington about the implications of a British departure from the EU," he said.
However, BBC political editor Laura Kuenssberg said a Brexit-supporting cabinet minister had stressed that Obama's view "was not the settled view in the USA. The Republicans don't agree and there is disquiet at his blatant meddling in UK politics".
The minister had suggested Ted Cruz supported Brexit, she added.
Speaking to the paper, Mr Obama said that the US's relationship with the UK had been "forged as we spilt blood together on the battlefield".
He went on to say the UK had benefitted from being inside the EU in terms of jobs, trade and financial growth, and that it "magnifies" the UK's global influence.
"This kind of co-operation - from intelligence sharing and counter-terrorism to forging agreements to create jobs and economic growth - will be far more effective if it extends across Europe. Now is a time for friends and allies to stick together," he wrote.
Former US State Department spokesman James Rubin told BBC Breakfast the president had not offered any words of reassurance about Britain's future relationship with the US if it left the EU because "it won't be OK".
"We have a phrase in America: 'Friends don't let friends drive drunk,'" he said, adding that it would be "a big mistake for Britain to leave the EU and set asunder what has been a very successful relationship".
But Vote Leave's Boris Johnson said although he was a "big fan" of Mr Obama, remaining in the EU is "clearly something we have a disagreement on".
He said: "America's a proud democracy built on principles of liberty. It is hypocritical for us to be told by America to embroil ourselves ever more deeply in a structure which would be absolutely alien to American traditions.
"I think most Americans would accept that there is something rum about asking us to subordinate our democracy in this way, when America would not dream in a million years of doing likewise."
Mr Johnson originally criticised Mr Obama in an article in the Sun but has since been criticised for making comments about the president's "part-Kenyan" ancestry.
Tory MP Iain Duncan Smith, who is also part of the Vote Leave campaign, echoed Mr Johnson's comments, adding: "I can imagine no circumstances under which he would lobby for the US Supreme Court to be bound by the judgements of a foreign court."
Former British army commander Richard Kemp told the BBC Mr Obama's comments on security were "diametrically opposite to the reality" and staying in the EU would be worse for UK's national security and for international security.
Mr Obama's UK stay is part of a tour taking in Germany and Saudi Arabia, which he left on Thursday after having discussions with King Salman on issues including Iran, Syria, Yemen and the fight against so-called Islamic State militants.
Barack Obama has urged the UK to stick with the EU, as he began his final trip to Britain as US president by having lunch with the Queen.