When thousands of migrant children ended up stranded in U.S. Border Patrol stations last spring, President Donald Trump’s administration characterized the crisis as a spontaneous result of the record crush of migrants overwhelming the U.S. immigration system. But the backup also was a result of policy decisions that officials knew would ensnare unaccompanied minors in bureaucratic tangles and leave them in squalid conditions, according to dozens of interviews and internal documents viewed by the Washington Post.

The policies, which administration officials began pursuing soon after Trump took office in January 2017, made it harder for adult relatives of unaccompanied minors to secure the children’s release from U.S. custody. Enhanced vetting of sponsors — including fingerprints and other paperwork — and sharing that information between child welfare and immigration authorities slowed the release of children and exposed sponsors to deportation.

The government knew the moves would strain child shelters, according to documents and current and former officials, but it was aimed at sending a message to Central American migrants: Coming to the United States illegally has consequences.

Administration officials said the policy was designed to protect children from potential abusers or criminals, but they also wanted to create a broad deterrent effect; they reasoned that undocumented migrants might hesitate to claim their children for fear of being deported. Authorities weighed deterrence — a central aspect of U.S. immigration policy under both President Barack Obama and Trump — against the possibility of children crowding into border stations. And they chose to push forward, knowing what would result.

“This will strain bed capacity,” officials wrote in a discussion paper in February 2018.

The approach caused thousands of unaccompanied minors to be stranded in U.S. custody and exacerbated the appearance of a crisis on the southern border — a major element underlying the administration’s public request for billions of dollars in additional funding from Congress.

According to current and former government officials, and e-mails and memos detailing the Trump administration’s strategy, it is clear they knew that without enough beds in government shelters, children would languish in Border Patrol stations not equipped to care for them, making the government a target of lawsuits and public criticism — both of which occurred.

A key figure in that strategizing, Chad Wolf, was sworn in Wednesday as the new acting secretary of the Department of Homeland Security.

Some senior officials acknowledged in interviews that they expected some children to remain in custody for longer periods of time, but they said the policy was developed with child safety in mind; they did not want children to be released to smugglers or criminals.

“My number one concern on this was making sure that kids were safe,” Tom Homan, former acting director of U.S. Immigration and Customs Enforcement, said in an interview. “It was never easy. You have to weigh the operational concerns, and the humanitarian concerns.”

Said acting ICE Director Matthew Albence: “The goal was to prevent these children from coming on this dangerous journey.”

Officials have argued that shortening the time that children are held in federal custody will boost the incentive for migrant families to seek entry into the United States.

“The shorter the stay, the more likely they’re willing to take it on,” Homan said. “If I think I’ll be detained for a year, I might not come. But if I’ll be detained for a week and be released, that may convince me to make that trip.”