WASHINGTON — Since the early days of the coronavirus pandemic, White House officials had discussed the possibility of temporarily halting immigration into the U.S. — but until a late night tweet by their boss, the plans were mostly theoretical.

That all changed around 10 p.m. ET on Monday when Trump declared on Twitter that new arrivals would be halted. “I will be signing an Executive Order to temporarily suspend immigration into the United States!” he wrote, setting off widespread confusion inside and outside of the administration, and a scramble by aides to finalize the mandate in under 48 hours.

Moments after the president sent out his tweet, aides told NBC News they had been aware that an immigration order had been under consideration, but they seemed caught off guard by the timing and were not able to offer any details, or even what the intended purpose was.

The next morning, officials tried to tamp down the confusion, but still had few details to offer. One senior administration official said that an executive order was still being considered — suggesting the move wasn’t a done deal — and that it would only apply to certain immigration categories. But the official was unable to say who would be exempt or if any countries would be excluded.

Another administration official tried to caution that farmworkers would likely be exempt, and downplayed the impact the action would have on U.S. policy.

Meanwhile, confused and concerned businesses began calling the White House to find out what the ban would mean for their workforces, said one White House aide — particularly farmers, who were already struggling to get the migrant labor they needed amid the outbreak. Democrats quickly assailed Trump's decision as racist, with House Democratic Caucus Chairman Hakeem Jeffries, D-N.Y., tweeting that the president was the "Xenophobe. In. Chief."

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

White House officials said drafts of an executive order, which were being driven by White House adviser Stephen Miller, had been circulating before the president's tweet.

But officials weren’t sure which version the president was planning to sign, and none had been fully vetted by lawyers at the White House general counsel’s office and Justice Department to determine if they would be able to withstand a likely court challenge by pro-immigration groups. One draft executive order reported by Bloomberg News said the halt on immigration would be for 90 days, not the 60-day pause Trump later said he would be ordering.

Top administration officials, pressed by reporters on what the order would entail, were vague on details. National Security Adviser Robert O’Brien, asked what Trump had meant when he called the ban a "temporary" one, said only: “We’ll have to wait and see. Look, we don't know that the time horizon is for the fight against the virus.”

It wasn’t until Tuesday evening that Trump provided more clarity, saying during the daily coronavirus press briefing that it would apply only to those seeking a green card and that temporary workers wouldn’t be included in a stop on immigration that would last at least 60 days, and possibly longer.

But behind the scenes Tuesday night at the White House, staffers were still trying to write up a final version of the executive order and officials continued to downplay the possibility of Trump signing a version the next day.

Trump had other plans. The president tweeted at 7 a.m. on Wednesday that he would be signing the order that day, in an attempt to light a fire under staffers, one official said.

Throughout the day on Wednesday, administration lawyers continued to race to try to get the necessary review done. When asked if Trump would indeed sign something that day, counselor to the president Kellyanne Conway said it was “a matter of when it’s ready,” but added Trump was “itching” to sign it. White House press secretary Kayleigh McEnany said Wednesday afternoon that the order was still being finalized.

It wasn’t until after 6 p.m. Wednesday that Trump, in his daily coronavirus briefing, said that he had just signed the executive order and the White House send out the text, finally giving clarity nearly two days after his first tweet on what would happen to the thousands of immigrants seeking to come to the U.S. as permanent residents and the business dependent on them.

The White House didn't waste time in seeking to weaponize the move to attack Democrats.

In a call with surrogates Thursday morning, Miller — the White House's fiercest advocate for limiting immigration — encouraged participates to use the measure as a political wedge.

"We all need to be out there publicly promoting this vital action, and emphasizing that we have a president that stands with American workers and we have a political opposition in this country that does not," Miller said, according to a person who participated in the call.

"The most important thing is to turn off the faucet of new immigrant labor," said Miller, according to the person. "Mission accomplished with signing that executive order."