LONDON — When Scottish voters were deciding last year whether to stick with the United Kingdom or ditch the three-century-old union, the United States largely stayed out of it.

LONDON — When Scottish voters were deciding last year whether to stick with the United Kingdom or ditch the three-century-old union, the United States largely stayed out of it.

For most of the in-or-out referendum campaign, U.S. officials kept to the line that it was up to the people of Scotland to decide. Given the circumstances of America’s founding, to do otherwise could have been a little awkward.

It was only toward the end of the campaign that President Barack Obama made his views known, and only then rather subtly. On the eve of the vote, the White House tweeted his hope that the U.K. would remain "strong, robust and united."

A day later, Scottish voters demonstrated that they agreed.

But now Britain is facing another existential choice — a vote within the next two years on whether to stay in the European Union. And this time, Obama is being anything but subtle.

In an interview with the BBC aired Thursday evening, the president laid down a strong endorsement of Britain’s EU membership and suggested that a decision to get out could make Britain a far less valuable ally.

"Having the United Kingdom in the European Union gives us much greater confidence about the strength of the trans-Atlantic union," Obama told BBC North America editor Jon Sopel.

Britain’s EU membership, Obama said, had helped make the world "safer and more prosperous. And we want to make sure that the United Kingdom continues to have that influence."

For British voters, the message was hard to miss.

And the reaction was immediate. Those campaigning for a "Yes" vote cheered the intervention; those hoping Britain leaves the 28-member union cried foul at American meddling and told the president to butt out.

Former environment secretary Owen Paterson, a leading Euroskeptic, played the history card, telling the BBC that the United States "two centuries ago fought not to have laws imposed on them. So I don’t think he’s in a strong position when we want to make our own laws in our own Parliament."

Others made more contemporary arguments. Nigel Farage, leader of the U.K. Independence Party, fired off a stream of tweets that used Obama’s comments as fresh ammunition for his anti-EU crusade:

"Backwards-looking, outdated EU in an age of increasing globalisation is not the model by which UK should seek to maintain global influence."

On the pro-EU side, which polls indicate would win if the vote were held today, there was gratitude that Obama had not held back. Although Obama’s views on the EU vote were no secret, his comments to the BBC were more forthright than anything he’s said before.

Obama and his administration have hardly been shy lately about sending signals across the Atlantic to a country that Obama called America’s "best partner."

In part that may be due to a president who, in the final quarter of his presidency, has been more assertive and willing to take risks.

But it also reflects real concern in Washington that London has been wobbling lately in its traditional commitment to play a major role in world affairs.

Throughout the spring, a parade of former and current U.S. officials expressed anxiety that Britain would drop below the 2 percent NATO target for defense spending, which is seen as a critical measure of a nation’s willingness to engage in matters of global security.

British Prime Minister David Cameron was unwilling to commit to the target before a national election in May. In the BBC interview, Obama acknowledged having had an "honest conversation" with Cameron — diplo-speak for tough words.

But this month, Cameron’s government announced that the country would continue to hit 2 percent until the next election, in 2020. Obama called that move "really significant" and suggested that any tension over the issue was long forgotten — just as other wounds in the "special relationship" have healed.

"Great Britain has always been our best partner. Well, you know, I guess you could go back to 1812," Obama said, laughing.

"When we tried to burn this place down?" Sopel asked helpfully.

"Yeah, right, right," Obama said. "But that’s ancient history."