WASHINGTON -- The government's top health official could barely conceal his discomfort. As Health and Human Services secretary, Alex Azar was responsible for caring for migrant children taken from their parents at the border. Now a Democratic senator was asking him at a hearing whether his agency had a role in designing the Trump administration's "zero tolerance" policy that caused these separations.

The answer was no.

"We deal with the children once they're given to us," responded Azar. "So we don't -- we are not the experts on immigration."

Get Breaking News Delivered to Your Inbox

Separating families while sidelining the agency responsible for caring for the children was only one example of a communication breakdown in the federal government that left immigrant children in limbo, parents in the dark about their whereabouts and enraged Americans across the country.

Today, the Trump administration is still dealing with the fallout: It's still not clear how officials will implement the policy or comply with a court order requiring that families be reunited within 30 days.

Instead, the administration is hoping Congress will fix the mess, despite its recent failure to pass immigration legislation.

"We are happy to change the policy when Congress gives us the tools to do it. That's what we're asking for," Marc Short, White House director of legislative affairs, said on MSNBC.

The idea of separating families goes back to the first two months of the Trump presidency. John Kelly, then the Homeland Security secretary, said it could be used as a deterrent. But the notion was quickly dropped, even as President Trump pushed a hard line on immigration, a crucial issue for his political base.

But behind the scenes, senior policy adviser Stephen Miller and others hadn't given up on the concept. It suddenly reappeared this spring after a persistent spike in illegal crossings. It took the form of the zero-tolerance policy announced by Attorney General Jeff Sessions that requires criminally prosecuting anyone coming to the U.S. illegally. Sessions and others argued families would have to be separated because children can't go to jail with their parents.

How or whether families would be reunited wasn't much of a concern to the policymakers, according to administration officials and others with knowledge of the discussions who spoke to The Associated Press on condition of anonymity. That lack of planning was evident in an interview Kelly, now White House chief of staff, did with NPR in May.

"The children will be taken care of -- put into foster care or whatever -- but the big point is they (the parents) elected to come illegally to the United States," he said.

The policy sowed confusion and anger not only in the border region, but in Washington. There was a lack of coordination among some of the government agencies involved in the process, the officials said. And there were multiple agencies involved: Customs and Border Protection, part of Homeland Security, detains immigrants. Health and Human Services is responsible for caring for children. Adults are referred to the Justice Department for prosecution. After those cases are resolved -- generally a quick process -- the adult immigrants are detained by Immigration and Customs Enforcement, another DHS agency.

Children were being sent hundreds of miles away from their parents and parents were unable to access hotlines to help them find their children. Some were deported without their kids. There was no system set up beforehand to link families and no plan on how to bring them back together, the officials said. More than 2,000 children were being separated from about 2,000 parents.

Religious and humanitarian leaders decried the policy. Doctors warned of serious trauma from separation. A pediatrician spoke of seeing a toddler weeping uncontrollably in a shelter and staff prevented from comforting her. Audio leaked of Border Patrol officers joking amid sobbing children.

As the crisis worsened, Mr. Trump tried to blame Democrats. Sessions quoted the Bible in his defense of the policy. Homeland Security Secretary Kirstjen Nielsen took questions during a tense White House press briefing and said there wasn't a policy to separate children. She was later heckled at a Mexican restaurant where she was eating dinner.

As criticism became more intense, Mr. Trump sought to calm the situation, the officials said. He had initially wanted to sign a full immigration bill as part of an executive order, but was told by attorneys that it wasn't possible, they said.

So, instead, Mr. Trump said he wanted an order written, and written quickly, they said. By midday on June 20, about six weeks after the policy started, Mr. Trump had signed papers that stopped separation -- but also still required 100 percent criminal prosecution for improper entry.

"We're going to have strong, very strong borders, but we're going to keep the families together," Mr. Trump said.

Now, the administration is arguing over how to implement the hastily formed order. They're struggling with how to reunite the families -- pushed by a court order this past Tuesday requiring they do so within 30 days, and within 14 days for children younger than 5.

While administration officials insist they know where all the children are, there has been no clear plan on how families will be reunited. Parents are still detained. Some 500 children were already returned to their parents, but those kids never made it out of Border Protection custody.

Some White House aides were determined to reunite families with their children as soon as possible, recognizing it was the only way to put the episode behind them. But another group, including Miller and many at the Justice Department, were advocating a more combative approach, prioritizing removals and prosecutions. Any shift toward the humanitarian concerns, some in that camp have argued, would be a sign of weakness that would reflect poorly on the president, the officials said.

Mr. Trump continues to advocate immediate removal, without an appearance before a judge or other due process, for those apprehended entering the country illegally.

Vice President Mike Pence and Nielsen met with Central American leaders Thursday to discuss the number of migrants trying to cross into the U.S.

In a speech in Guatemala, he said the U.S. was working to reunite families "from your nations who've been caught trying to illegally enter the United States - because we believe that we can -- as the old book says -- "do justice and love kindness."

But Pence also cautioned: "If you want to come to the United States, come legally, or don't come at all."