Federal officials are planning to open three emergency shelters this month to house approximately 3,000 to 4,000 unaccompanied children who have migrated across the U.S. border, part of an effort to ensure children do not languish in crowded jails.

The shelters are expected to be located on two U.S. military bases and at a facility in South Texas, officials said. Authorities have been considering opening shelters on Malmstrom Air Force Base outside Great Falls, Mont., and on two Army bases: Oklahoma’s Fort Sill, which housed minors in 2014, and Fort Benning in Georgia. Officials did not specify which bases would house the children.

The Department of Health and Human Services plans to shelter 2,000 children at the military facilities and 1,600 at a temporary emergency influx shelter in Carrizo Springs, Tex., a compound that formerly housed oil-field workers about two hours southwest of San Antonio. Federal officials said a private contractor will run the Texas facility, and HHS is expected to run the military shelters.

“HHS plans to start placing children at Carrizo Springs as soon as possible,” said Evelyn Stauffer, a department spokeswoman. Children will be placed at military facilities soon.

All children will be housed in dormitory-style buildings until case workers can place them with a parent or sponsor in the United States, but they will not have the educational programming or recreational activities that are normally required in child shelters.

HHS officials alerted shelters last week that the department expects to run out of money and will no longer fund English classes, art supplies, soccer coaches and other nonessential services for children in custody.

U.S. Border Patrol agents have apprehended 56,278 unaccompanied minors this fiscal year, a 74 percent increase over the same time last year, and new government data obtained by The Washington Post showed that many of the 2,000 unaccompanied migrant children in overcrowded Border Patrol facilities had been there beyond legally allowed time limits, including some who are 12 or younger. Government agencies have blamed breakdowns in the bureaucratic systems for the delays.

The crush of migrants has been putting HHS on track to house the largest number of children in its history. HHS had 13,200 minors in custody as of Sunday, most of them teenage boys. Minors stay in the shelters for an average of 48 days, but some can stay for months.

May marked the third consecutive month that overall border apprehensions topped 100,000. Most are families and unaccompanied minors from northern Central America, with some fleeing violence and others seeking work in the United States.

President Trump declared a national emergency at the border in February and has urged Congress to pass a $4.5 billion spending package that includes nearly $2.9 billion for HHS programs that care for unaccompanied minors. HHS is facing budget strains because the level of unaccompanied minors entering the country has soared well beyond expectations.

“Congress was warned for months this would happen without emergency funding,” Russ Vought, acting director of the Office of Management and Budget, said on Twitter. “We have a border crisis that cannot be ignored and this is what running out of funds looks like.”

The spending request also includes money for enforcement, and Trump has promised to go in a “tougher” direction on immigration. Federal officials last year separated children from their parents at the border in a failed attempt to deter illegal immigration. Officials also created strict vetting requirements for sponsors that left many parents afraid to claim their children, meaning minors stayed in custody for months instead of weeks.

Rep. Rosa L. DeLauro (D-Conn.), chair of the House Appropriations subcommittee on health and human services, told CNN on Thursday she would fund the $2.9 billion in a “nanosecond” if officials could guarantee that children are held in state-licensed shelters and quickly released to parents or sponsors. She said the Trump administration should allow parents to claim their children without fear of being deported.

DeLauro called on Republicans to accept her conditions so that HHS can receive the money.

HHS’s budget crunch has rattled advocates for immigrants and shelter workers, who said cutting physical education, classroom study and legal aid could endanger children’s physical and mental health.

Federal contractors are likely to be affected by the budget shortfall on a rolling basis, HHS said Friday, depending on their individual budgets. As an example, legal-service providers were still offering presentations and counseling to migrant children in shelters this week, but that could change as funding dwindles.

“It’s already so stressful right now,” said Jennifer Podkul, senior director for policy and advocacy at Kids in Need of Defense, a nonprofit group that provides legal aid to minors. She said children are scared because of the uncertainty. “They don’t understand a lot of the process. They’re away from their family. We’re just worried about their emotional well-being right now.”

Federal law requires Border Patrol agents to swiftly shuttle minors who cross the border without their parents from border jails to licensed child shelters, usually within three days, where they are to receive food, medical care and housing until case workers can place them with a sponsor. A 1997 federal consent decree also requires schooling Mondays through Fridays in math, science, reading, writing, social studies and physical education. It also requires two to three hours of outdoor activity.

But HHS officials say the federal Antideficiency Act requires them to avoid running over budget, which is prompting the agency to cut services that are not “directly linked to the safety of human life.”

Shelter officials said this week that they hoped to preserve classrooms, soccer and other activities; some were closely examining their budgets and considering using other funds to cover education and playtime.

BCFS Health and Human Services, which runs shelters, said in a statement that the organization “has not and will not cancel or alter the services,” because it would violate state licensing standards.

“We will continue to provide these services through emergency funding from our parent organization,” the statement said. “The health and well-being of those in our care are of the utmost importance and we hope there is a rapid resolution to this funding issue.”