When President Donald Trump declared at the Pentagon Friday he was enacting strict new measures to prevent domestic terror attacks, there were few within his government who knew exactly what he meant. Administration officials weren’t immediately sure which countries’ citizens would be barred from entering the United States. The Department of Homeland Security was left making a legal analysis on the order after Trump signed it. A Border Patrol agent, confronted with arriving refugees, referred questions only to the President himself, according to court filings. Saturday night, a federal judge granted an emergency stay for citizens of the affected countries who had already arrived in the US and those who are in transit and hold valid visas, ruling they can legally enter the US. Trump’s unilateral moves, which have drawn the ire of human rights groups and prompted protests at US airports, reflect the President’s desire to quickly make good on his campaign promises. But they also encapsulate the pitfalls of an administration largely operated by officials with scant federal experience. It wasn’t until Friday – the day Trump signed the order banning travel from seven Muslim-majority countries for 90 days and suspending all refugee admission for 120 days – that career homeland security staff were allowed to see the final details of the order, a person familiar with the matter said. The result was widespread confusion across the country on Saturday as airports struggled to adjust to the new directives. In New York, two Iraqi nationals sued the federal government after they were detained at John F. Kennedy International Airport, and 10 others were detained as well. In Philadelphia, a Syrian family of six who had a visa through a family connection in the US was placed on a return flight to Doha, Qatar, and Department of Homeland Security officials said others who were in the air would be detained upon arrival and put back on a plane to their home country. Asked during a photo opportunity in the Oval Office Saturday afternoon about the rollout, Trump said his government was “totally prepared.” “It’s working out very nicely,” Trump told reporters. “You see it at the airports. You see it all over. It’s working out very nicely and we’re going to have a very, very strict ban, and we’re going to have extreme vetting, which we should have had in this country for many years.” The policy team at the White House developed the executive order on refugees and visas, and largely avoided the traditional interagency process that would have allowed the Justice Department and homeland security agencies to provide operational guidance, according to numerous officials who spoke to CNN on Saturday. Homeland Security Secretary John Kelly and Department of Homeland Security leadership saw the final details shortly before the order was finalized, government officials said. Friday night, DHS arrived at the legal interpretation that the executive order restrictions applying to seven countries – Iran, Iraq, Libya, Somalia, Syria, Sudan and Yemen – did not apply to people with lawful permanent residence, generally referred to as green card holders. The White House overruled that guidance overnight, according to officials familiar with the rollout. That order came from the President’s inner circle, led by Stephen Miller and Steve Bannon. Their decision held that, on a case by case basis, DHS could allow green card holders to enter the US. There had been some debate whether green card holders should be even allowed to board international flights. It was decided by the Department of Homeland Security they could fly to the US and would be considered on a case-by-case basis after passing a secondary screening. But the guidance sent to airlines on Friday night, obtained by CNN, said clearly, “lawful permanent residents are not included and may continue to travel to the USA.” As of Saturday afternoon, Customs and Border Protection continued to issue the same guidance to airlines as it did Friday, telling airlines that fly to the US that green card holders can board planes to the US but they may get extra scrutiny on arrival, according to an airline official. Before the President issued the order, the White House did not seek the legal guidance of the Office of Legal Counsel, the Justice Department office that interprets the law for the executive branch, according to a source familiar with the process. White House officials disputed that Sunday morning, saying that OLC signed off and agency review was performed. A source said the creation of the executive order did not follow the standard agency review process that’s typically overseen by the National Security Council. Separately, a person familiar with the matter said career officials in charge of enforcing the executive order were not fully briefed on the specifics until Friday. The officials were caught off guard by some of the specifics and raised questions about how to handle the new banned passengers on US-bound planes. Regarding the green card holders and some of the confusion about whether they were impacted, the person familiar with the matter said if career officials had known more about the executive order earlier, some of the confusion could have been avoided and a better plan could be in place. Administration officials also defended the process Saturday. They said the people who needed to be briefed ahead of time on the plane were briefed and that people at the State Department and DHS who were involved in the process were able to make decisions about who to talk and inform about this. Bannon and Miller were running point on this order and giving directives regarding green cards, according to a Republican close to the White House. But even after the Friday afternoon announcement, administration officials at the White House took several hours to produce text of the action until several hours after it was signed. Adviser Kellyanne Conway even said at one point it was not going to be released before eventually it did get sent out. Administration officials also seemed unsure at first who was covered in the action, and a list of impacted countries was only produced later on Friday night, hours after the President signed the document at the Pentagon. This story has been updated to include the White House’s response on the issue of Justice Department review.