Scotland’s decision to remain part of the United Kingdom has narrowly averted what could have been a geopolitical catastrophe for the Obama administration and its allies at a time when they’re launching a war against the Islamic State and shoring up defenses against a newly emboldened Russia.

Coming just two weeks after NATO countries reaffirmed their alliance at a summit in nearby Wales, a vote for Scottish independence could have sent a much different message.

Observers warned that a Scottish break-off would weaken the United Kingdom as a NATO member, not to mention imperil its seat on the U.N. Security Council and other key bodies where the U.K. has been a dependable friend of the U.S. Scottish separatists had even floated the prospect of not joining NATO if they gained independence. 

President Obama on Friday praised the result of the referendum, while congratulating the people of Scotland for their "full and energetic exercise of democracy." 

"We have no closer ally than the United Kingdom, and we look forward to continuing our strong and special relationship with all the people of Great Britain and Northern Ireland as we address the challenges facing the world today," Obama said. 

Even before the vote, Obama had left no doubt on his position on the referendum. “The UK is an extraordinary partner for America and a force for good in an unstable world. I hope it remains strong, robust and united,” Obama tweeted a day earlier. 

His top spokesman, Josh Earnest, said the president believes the U.K. is a strong partner and “we want to keep it that way.”

The results of the referendum were a clear victory for those who want to keep the United Kingdom united. The final vote was 55-45 percent, against independence.

British Prime Minister David Cameron had campaigned hard against a Scottish breakaway, and the result is a relief for his administration.

Analysts said Cameron was in very real danger of losing his post if the vote succeeded. Nile Gardiner, director of the Margaret Thatcher Center for Freedom, told Fox News before the results were announced that he was in danger of losing credibility at a vital time in terms of the U.K.-U.S. relationship.

“America needs Great Britain to stand alongside it, shoulder to shoulder in the face of the ISIS threat in Iraq and Syria, and so if you have a prime minister who is fighting for his survival, that isn’t very good news in terms of building a coalition against ISIS,” he said.

Aside from the U.K.’s global status, also on the line were Scotland’s assets and resources, including nuclear weapons housed there. If Scotland declared independence, the U.K. would likely have had to find a new temporary location for its nuclear submarines.

Gardiner said this would have threatened both British and American security.

With Scotland rejecting independence and Cameron’s rule preserved for now, the U.K. is free to continue coordinating with the United States and other nations on its emerging campaign against the Islamic State in Iraq and Syria.

Underscoring the urgency of that partnership, France claimed to have conducted its first airstrikes against the group, launching a strike against an ISIS target in Iraq on Friday.

Fox News’ Greg Palkot contributed to this report.