FILE– Robert Rodriguez, right, a U.S. Border Patrol agent, helps apprehend immigrants who were illegally crossing the border, in McAllen, Texas, Oct. 3, 2018. The Trump administration did not tell key government agencies about its “zero tolerance” immigration policy before publicly announcing it in April, leaving the officials responsible for carrying it out unprepared to handle the resulting separations of thousands of children from their families, according to a government report released on Oct. 24. (Lynsey Addario/The New York Times) — NO SALES. —

WASHINGTON — The Trump administration did not tell key government agencies about its “zero tolerance” immigration policy before publicly announcing it in April, leaving the officials responsible for carrying it out unprepared to handle the resulting separations of thousands of children from their families, according to a government report released Wednesday.

The Department of Homeland Security, which apprehends border crossers, and the Department of Health and Human Services, which cares for separated migrant children, were both caught off guard when Attorney General Jeff Sessions announced plans to criminally prosecute anyone who crossed the border illegally, the report said.

“There must be consequences for illegal actions,” Sessions said before dozens of sheriffs from counties on the United States’ border with Mexico.

Because they did not know about the zero tolerance policy in advance, officials at the Department of Homeland Security said, they did not take steps to prepare for the resulting family separations. Staff members at the Department of Health and Human Services said their leaders told them not to prepare for an increase in children separated from their families because Homeland Security officials claimed that they did not have an official policy of separating parents and children, according to the report, which was prepared by the Government Accountability Office, Congress’ nonpartisan investigative arm.

The enforcement of the policy led to the separation of nearly 3,000 children from their parents, setting off weeks of national protests, with Democrats and many Republicans calling on President Donald Trump to end it. The president eventually relented and moved to halt the family separations, though the government struggled in some cases to reunite those it had already separated.

“This disturbing GAO report shows the tragic consequences of carrying out a cruel and misguided policy impacting thousands of families without any preparation or prior notification to the agencies charged with implementing it,” said Rep. FrankPallone Jr., D-N.J., who requested the report.

Katie Waldman, a spokeswoman for Department of Homeland Security, said federal agencies had reunited thousands of children with their families under a court order.

“In addition, we have prevented the reunification of children with adults who were not their parents, or were unsafe for children,” she said, citing reports of child abuse or parents with criminal records. She said the Trump administration continues to criminally prosecute single adults apprehended at the border. She declined to elaborate on other details of the report.

The report comes as the Trump administration is grappling with thousands of migrants, mainly from Central American countries, seeking asylum on the southwestern border. An estimated 7,000 migrants recently entered Mexico fleeing the grinding poverty and violence of El Salvador, Guatemala and Honduras. Many of the migrants said they were headed to the United States, frustrating Trump, who has said without proof — then backtracked — that the caravan of migrants contains “Middle Easterners” and suggested that the migrants were induced to make the journey by his Democratic opponents.

Data released Tuesday by Customs and Border Protection, the parent agency of the Border Patrol, showed that the agency apprehended 16,658 people in families in September, a record. Such arrests reached 107,212 for the 2018 fiscal year, which ended Sept. 30, exceeding the previous high of 77,857 in the 2016 fiscal year. In total, nearly 400,000 people were apprehended by border agents in the 2018 fiscal year.

The zero tolerance policy was supposed to serve as a deterrent to families traveling with children. But from the outset, the policy seemed poorly planned.

According to the Government Accountability Office report, days after Sessions announced the policy, leaders of agencies at the Department of Homeland Security, including Customs and Border Protection, sought guidance from Kirstjen Nielsen, the Homeland Security secretary, on how to enforce it.

In May, the department finally issued a memo directing border agents to refer all individuals crossing the border illegally to the Justice Department for prosecution. Adults were turned over to Immigration and Customs Enforcement and placed in detention facilities. Migrant children were sent to the Department of Health and Human Services.

Under a 1997 court agreement, migrant children cannot be detained for more than 20 days.

Many of the children were placed in government-run shelters thousands of miles away from their parents. But the report found that in some cases, officials at the Department of Homeland Security did not notify staff at the shelters that a child had been separated from his or her parents. One shelter’s officials told the Government Accountability Office that for some of the children in its care, they had learned that the child was separated only when the child told them.

It was not until July 6, 16 days after Trump signed an executive order aimed at ending the family separations and 10 days after a federal court halted the policy, that federal agencies developed a system to determine whether children were separated from their parents, the report said.

Most of the separated children have been reunited with their families under a court order. But Pallone said the administrationtook too long to develop a process to identify and reunite families.

“The gross failures detailed in this report will be long remembered, but hopefully never repeated,” he said.