The White House’s hastily crafted executive order to end child separations spurred confusion and fights within the federal government, and second-guessing from the president who had demanded the order in the first place.

Amid continuing fallout from the Trump administration’s family separation policy, and a disjointed retreat earlier this week, senior officials met Friday to craft a plan for reuniting immigrant children with their parents or guardians, though it remained unclear how long that work will take.

The midday meeting was designed for officials to hash out exactly how they would reunite the more than 2,500 migrant children who have been separated from their parents since the practice went into effect in early May, according to officials involved in the discussions, who, like others, spoke on the condition of anonymity to offer candid insights into internal deliberations. Roughly 500 children have already been reunited with a parent or guardian, officials have said.

The Friday meeting capped a tumultuous week in which administration officials rushed through an executive order that relieved the political pressure on President Trump but intensified friction between the Justice Department and the Department of Homeland Security.

By Wednesday morning, the president had become convinced that he needed a way to calm the criticism, according to people familiar with the discussions, and he felt confident that Republicans in Congress would push through immigration legislation ending the family separation practice — so he might as well get ahead of it. A vote on the measure was eventually postponed until next week, but it does not appear to have enough votes to pass.

Demonstrators rally outside a holding facility for migrant children in Tornillo, Tex., on Thursday. (Andres Leighton/AP)

In private conversations with aides, Trump said he wanted to sign a full immigration bill as part of an executive order, which one administration official described as “a pretty insane idea.” The president was told by government lawyers that he could not change immigration law by fiat, said a person familiar with the discussions.

Trump then demanded that an executive order be written, and said he wanted it on his desk for signing by that afternoon, according to people involved in the discussions.

Given hours to produce a complex legal document, government lawyers crafted one that met the moment’s political demands but only added to confusion within the agencies tasked with implementing it.

The order has quieted much, but not all, of the public anger over the family separation issue. On Friday outside the Justice Department, about 100 protesters gathered in the rain chanting “Keep Families Together!”

Even that admonition, with which the administration now agrees, has provoked fights inside the government.

Thursday, the first day of enforcing the order, was marked by confusion.

That interpretation was relayed to CBP personnel along the southern border, and dozens of people who had been apprehended and sent to federal court for processing were suddenly removed from courthouses without criminal charges being filed against them.

Within the Justice Department, which prosecutes such cases, officials believed the executive order paved the way for parents to be held with their children for as long as necessary to resolve their cases, these people said.

White House officials gave little guidance in the early hours of the order, with Trump and his coterie of senior aides in Minnesota for a rally.

After CBP officials said there would be no referrals to the Justice Department of adults with children caught crossing the border, Justice Department officials became irate because that was not how they understood the policy, according to people familiar with the matter.

In many ways, the confusion echoed one of the administration’s most chaotic moments — when Trump signed an executive order in early 2017 banning visitors from majority Muslimcountries, leading to mass protests outside U.S. airports and much confusion for travelers.

In both instances, CBP personnel were left scrambling to quickly interpret and implement how the president’s command would be applied on the ground, with contradictory instructions and public statements in the immediate aftermath coming from multiple federal agencies.

On Thursday evening, officials from Homeland Security and the Justice Department gathered at the White House to discuss the issues, and over the course of the 90-minute meeting it became clear that CBP and Justice had wildly different understandings of what they were supposed to be doing, according to people familiar with the talks.

Senior White House adviser Stephen Miller, an outspoken proponent of tougher immigration policy, was unhappy that CBP had decided to halt referrals for prosecutionof parents illegally crossing the border with children, according to people familiar with the meeting. Homeland Security officials complained they had been given no guidance and had done the best they could with vague language.

Trump, for his part, has ruminated to aides that he should not have signed the order in the first place, according to people familiar with the conversations. The president seemed to be fed up with the topic Friday, as he publicly discouraged Republican lawmakers from trying to pass any new immigration laws before the midterm elections in November.

“Republicans should stop wasting their time on Immigration until after we elect more Senators and Congressmen/women in November,” Trump tweeted. “Dems are just playing games, have no intention of doing anything to solves this decades old problem. We can pass great legislation after the Red Wave!”

In the meantime, federal agencies continue to wrestle with how to deal with those families that have been detained or are likely to be detained soon.

A significant challenge for Homeland Security, in particular, is that its detention facilities are already near maximum capacity, according to officials.

U.S. Immigration and Customs Enforcement (ICE) currently has three “family residential centers” where migrant families can remain in custody together, but their combined capacity is only about 3,000 beds. According to the latest ICE statistics, the three facilities are nearly full.

On Friday, ICE requested information from government contractors about expanding its family detention capacity fivefold, “to accommodate up to 15,000 beds.” Its notice said the agency is seeking market information about the cost and logistics of adding new family-appropriate facilities, preferably in states along the Mexico border.

“The housing and other structures must appear residential and child-friendly rather than penal in nature,” the notice stated. “Facilities should not incorporate characteristics on the interior or exterior typically associated with secure detention facilities, such as high security fences, razor wire fencing, or heavy steel doors.”

Trump’s order also calls on the Defense Department to find space for migrant families, leaving military officials crafting plans on the fly to set up tent camps on bases with available land.

Pentagon officials on Friday said the department was drawing up plans for housing migrants. The officials stressed that the plans were not finalized and had been drafted in case they were needed.

“At this time there has been no request from DHS for DOD support to house illegal migrants,” Lt. Col. Jamie Davis, a Pentagon spokesman, said in an email.

One draft memo prepared for the secretary of the Navy called for “temporary and austere” detention camps for up to 25,000 migrants on abandoned airfields in Alabama, according to Time, which obtained a copy of the document.

The proposal also identifies a former naval weapons station near San Francisco and another facility at Camp Pendleton in southern California, each of which could house up to 47,000 people, Time reported.

White House officials were publicly silent on the executive order Friday, not taking questions as senior government officials huddled behind the scenes. Trump appeared with families of people killed by illegal immigrants and said the media should instead focus on those separations, which he called “permanent.”