The president’s whiplash-inducing order caught several people by surprise. Just a day before Mr. Trump signed it, one person close to the president said that he told advisers that separating families at the border was the best deterrent to illegal immigration and that he said that “my people love it.”

Even on Wednesday, Mr. Trump repeatedly changed his mind about precisely what he wanted to do, and how, until shortly before he signed the order.

Thursday night’s meeting was held in the White House Situation Room and lasted at least 90 minutes, according to four officials briefed on the discussion who described it on the condition of anonymity.

They said Customs and Border Protection officials forcefully argued that agents who are apprehending migrant families at the border cannot refer all of the adults for prosecution because the Justice Department and other law enforcement agencies do not have the resources to process each case.