But it was also a remarkable opportunity. After all, Nielsen had a much thinner résumé than her predecessors at the job: former governors, judges and upper-echelon government lawyers. James Nealon, who worked with Nielsen as the department’s assistant secretary for international engagement, describes her as “a super staffer.” But it’s a general rule of Washington that staff members, even super staffers, don’t become cabinet officers — much less when they’re still in their 40s.

Not long after Nielsen was sworn in as homeland security secretary in December 2017, according to a current and a former administration official, McAleenan alerted her to a rise in illegal border crossings. If the trend continued, he warned, by the spring — when border crossings typically peak — the immigration system would most likely be so overwhelmed that the department would no longer be able to process, much less interdict, new arrivals. Together with Thomas Homan, then the acting director of ICE, and L. Francis Cissna, then the director of Citizenship and Immigration Services — the agency that handles the country’s legal immigration procedures — he urged Nielsen to take some sort of drastic action.

One option McAleenan, Homan and Cissna presented to Nielsen, according to the current and former administration officials, was instituting a policy of separating migrant children from their families. Because of a consent decree known as the Flores settlement, C.B.P. is prohibited from holding immigrant children caught illegally crossing the border with their guardians for more than 20 days. This meant that adult immigrants, if they illegally came across the border with their children, would be released — often immediately or at the longest after 20 days — when their children were required to be released. Separating the children from their parents, department officials argued, would allow C.B.P. to detain the adults longer.

According to former senior administration officials, Kelly, when he was homeland security secretary, had been urged by other administration officials to institute such a family-separation policy. Publicly, Kelly said he was considering such a move. “I would do almost anything to deter the people from Central America to getting on this very, very dangerous network that brings them up through Mexico into the United States,” he told CNN in March 2017. But according to former senior administration officials, he privately rejected it, and the idea was tabled.

Now Nielsen rejected it as well. But as the border numbers kept rising, the pressure on Nielsen to do something only grew — and it was no longer coming from just her deputies. Toward the end of 2017, Gene Hamilton, Miller’s old ally at D.H.S., moved over to the Department of Justice, where he was reunited with Sessions, his old Senate boss. Not long after Hamilton’s arrival, the attorney general began to assert himself more aggressively on immigration matters. In early April 2018, Sessions announced that the Department of Justice would institute a policy of “zero tolerance” for undocumented immigrants. For the last two decades, under Democratic and Republican presidents, people who were caught crossing the border for the first time were typically charged with misdemeanors and then released. Under the zero-tolerance policy, all undocumented immigrants would be “met with the full prosecutorial power of the Department of Justice,” as Sessions put it.

The timing of the attorney general’s announcement caught Nielsen by surprise — and it presented her with a problem. For the Trump administration to be able to prosecute all undocumented immigrants, C.B.P. would have to refer their cases to the Justice Department, which would mean separating parents from their children while the parents awaited prosecution. Later that April, McAleenan, Homan and Cissna wrote Nielsen a memo recommending that D.H.S. start doing just that.

According to The Washington Post, which obtained a copy of the memo, they noted that the Trump administration had run a pilot zero-tolerance program along parts of the border in Texas and New Mexico for four months in 2017 and that the number of families trying to cross illegally had gone down 64 percent, only to rise again when the program was paused. After receiving the memo, Nielsen met with McAleenan, Homan and Cissna at the Ronald Reagan Building near the White House. There, according to former senior administration officials, she told them that she felt boxed in, but she agreed to their recommendation.