Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

In his maiden address to the U.N. General Assembly on Tuesday, President Donald Trump vowed to "totally destroy North Korea," drawing gasps from foreign delegates on the assembly floor.

Behind the scenes, the president's military advisers and senior U.S. diplomats have been working to reassure allies that they are committed to finding a diplomatic solution to the crisis in North Korea.

The mixed public messaging from Trump and his advisers over North Korea underscores one of the biggest foreign policy challenges in the Trump era.

Many of the president's own advisers were just as surprised by the president's U.N. remarks as the delegates, and found themselves having to allay fears among allies that the president will pursue hasty actions, without exhausting all possible diplomatic channels, including exerting more pressure on China and ratcheting up sanctions.

Secretary of Defense James Mattis sought to put an end to speculation Wednesday that a U.S. attack on North Korea was imminent, saying the administration is still dedicated to finding a diplomatic solution to North Korea's aggression.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

"We continue to press on the diplomatic level and that includes economic sanctions," Mattis told reporters. "At this time, we must also recognize the somber reality that military options must be available in order to protect our allies and ourselves."

Two defense and two diplomatic officials told NBC News that Trump and his advisers continue to explore contingency plans should the situation call for military action. But there has still been no movement of additional military equipment or personnel to the region beyond the standard rotations.

White House Chief of Staff John Kelly, left, reacts as he and first lady Melania Trump listen to U.S. President Donald Trump speak during the 72nd session of the United Nations General Assembly at U.N. headquarters on Sept. 19, 2017. Mary Altaffer / AP

The defense officials said that the U.S. has not seen any new or concerning movement of North Korean military equipment since the speech that would indicate another North Korean test is imminent, but at this point, Pyongyang has the ability to test with very little notice.

Dogged by leaks since taking office, Trump and his inner circle have grown increasingly secretive with policy planning, often leaving regional specialists and national security advisers in the dark.

Few at the National Security Council or State Department were consulted on the president's speech, drafted primarily by conservative aide Stephen Miller, with input from NSC spokesman Michael Anton and chief of staff John Kelly.

The White House did not respond to a request for comment on the input that went into the speech.

The administration fiercely pushed back in June when media reports suggested that a stern statement issued by the White House to Syrian President Bashar al-Assad claiming that "potential" evidence that another chemical weapons attack was planned had not been coordinated with the State Department or Pentagon.

This picture taken on May 14, 2017 and released from North Korea's official Korean Central News Agency (KCNA) on May 15 shows North Korean leader Kim Jong-Un (3rd R) inspecting a ground-to-ground medium long-range strategic ballistic rocket Hwasong-12 at an undisclosed location. AFP - Getty Images file

White House spokeswoman Sarah Huckabee Sanders told reporters that State Department, Defense Department and intelligence officials were "fully aware" of the situation before the White House released the cryptic statement.

More recently, Trump last month threatened "fire and fury" in response to North Korea's missile tests.

Asked on Sunday what the president meant, his ambassador to the U.N., Nikki Haley, told CNN's "State of the Union": "You have to ask the president what fire and fury meant. But I think we all know that basically if North Korea keeps on with this reckless behavior, if the United States has to defend itself or defend its allies in any way, North Korea will be destroyed. And we all know that."

Similarly, Mattis walked back some of the president's recent comments on North Korea, assuring journalists that there is always room for diplomacy, after the president wrote on Twitter that the time for talks is over.

"I take exception to the president's comments because you've got to be sure that you can do what you say you're going to do," Sen. John McCain, R-Ariz., told Phoenix radio station KTAR last month. "The great leaders I've seen don't threaten unless they're ready to act, and I'm not sure President Trump is ready to act."