(CNN) President Donald Trump believes next month's proposed summit with Kim Jong Un could end the decades-old threat of North Korea's nuclear program, should it go ahead as planned.

But earlier this year, just weeks before the Winter Olympics in South Korea that served as a critical diplomatic opening with Pyongyang, the President ordered his top national security officials to prepare to evacuate the families of all US military personnel living in South Korea, four current and former administration officials said.

The order was a provocative step that, had it been fully implemented, would have heightened tensions with North Korea and could have sent the region spiraling closer to war.

The presidential order is the clearest indication yet that Trump viewed war with North Korea as a real possibility, even as recently as the beginning of this year. At the time, Trump was convinced tensions could ultimately escalate beyond just rhetoric and was mulling military options against North Korea. The rapid shift from provocative steps to summit diplomacy illustrates the whipsaw approach the President has adopted on the global stage.

The dynamic took another turn Tuesday, when North Korea said the US should carefully consider the fate of the summit in view of what the North called "provocative military disturbances with South Korea," according to the North Korean state news agency.

Trump issued the directive earlier this year to H.R. McMaster, his national security adviser at the time, during a daily intelligence briefing, evoking deep concerns among the administration's top national security officials, who worried North Korea would interpret the move as the US preparing to go to war. They worried the Olympics could also be scuttled along with its promise of opening diplomatic avenues between North and South Korea.

McMaster directed his staff at the National Security Council to prepare a presidential memorandum ordering military dependents in South Korea to leave the country. Within a day, the memorandum made its way to chief of staff John Kelly's office.

"It was an order. It wasn't, 'I'm thinking about it,'" one senior administration official said of Trump's directive. "We saw it as a done deal."

Behind the scenes

Behind the scenes, Defense Secretary James Mattis and Kelly devised a compromise, according to two administration officials, and convinced the President to agree to a scaled-down directive that would bar military personnel in South Korea from bringing their families there during future tours, but avoid a dramatic evacuation, a senior administration official said. A new memorandum was drafted, but it too was never implemented.

Former US officials and North Korea experts said ordering the nearly 8,000 military dependents living in South Korea to leave the country would have set off alarm bells, heightening concerns about potential US military action at a time when Trump's bellicose rhetoric already had the region on edge.

"All chaos would have broken out," said Jung Pak, a former CIA official and deputy national intelligence officer at the National Intelligence Council. "This would have been a sure signpost for Kim (Jong Un) that the US was preparing for a military attack."

Christopher Hill, a former Assistant Secretary of State for East Asian and Pacific Affairs and US ambassador to South Korea, said an evacuation of military dependents would be a "huge step" that would "get everyone's attention."

"You bet it would be seen as a precursor to military action," Hill said.

The White House didn't respond to requests for comment on this story. A senior US defense official said there were broad discussions within the administration about US military posture on the Korean Peninsula in the weeks leading up to the Olympics.

Diplomatic entrée

The Olympics went forward unencumbered, giving way for Kim's sister to attend the games in South Korea and extend a personal invitation to the South Korean President to meet with her brother for the first top-level inter-Korean talks in more than a decade. That diplomatic entrée led to several more, with Trump receiving an invitation of his own in March to meet with Kim.

It's not clear what prompted Trump to suddenly demand the evacuation of military dependents from South Korea. But the order came as the President and his advisers mulled the possibility of launching a " bloody nose " preventive strike on North Korea.

One former senior administration official said they believed at the time that the President wanted to send a signal to Mattis and the top US military brass that "he was serious about studying military options for North Korea."

"Mattis and company were reluctant to give him options in case he said, 'Let's go with it,'" the former official said. "He wanted to wake them up."

Another administration official said Trump believed it would be foolish to keep the nearly 8,000 military dependents living in South Korea if there was a chance of tensions spiraling out of control. The official said the President wasn't preparing to strike North Korea, but believed North Korea might take military action.

The idea of moving the families of US servicemembers out of South Korea was publicly floated by several hawkish Republican senators a month before Trump directed the action in January, namely Sen. Lindsey Graham, of South Carolina, and Sen. Tom Cotton, of Arkansas. Both senators speak regularly with the President.

Representatives for Graham and Cotton declined to comment on whether the senators discussed the matter privately with Trump.

Other signs

There are other signs the administration was at least contemplating larger scale evacuations on the Korean Peninsula in preparation for potential violence breaking out. The administration's pick for ambassador to Seoul, Victor Cha, was asked during meetings by NSC officials whether he felt prepared to manage diplomatic efforts that would surround a "bloody nose" US strike, including the potential evacuation of American civilians from Seoul, a source familiar with the dynamic told CNN. Cha expressed concerns about such a strike, and later was dropped from consideration

The President's directive on military dependents underscores the extent to which he was prepared to go to the brink of war with North Korea before a veritable diplomatic opening presented itself.

While the administration was in sync on the need to apply maximum diplomatic and economic pressure on North Korea, the President's bellicose rhetoric and contemplation of military action against North Korea stoked deep divisions in the administration's top ranks.

That is partly why the President's advisers were stunned when he readily accepted Kim's invitation to meet for talks during an impromptu March meeting with the South Korean national security adviser in the Oval Office.

Now, the President has abandoned his bellicose rhetoric and personal jabs at the North Korean leader. In its place, the President has turned strikingly optimistic about the prospects of reaching a peace deal with his North Korean counterpart, whom he has repeatedly praised.