MCALLEN, Tex. — Many of the nearly 2,000 unaccompanied migrant children being held in overcrowded U.S. Border Patrol facilities have been there beyond legally allowed time limits, including some who are 12 or younger, according to new government data obtained by The Washington Post.

Federal law and court orders require that children in Border Patrol custody be transferred to more-hospitable shelters no longer than 72 hours after they are apprehended. But some unaccompanied children are spending longer than a week in Border Patrol stations and processing centers, according to two Customs and Border Protection officials and two other government officials who spoke on the condition of anonymity to discuss the unreleased data. One government official said about half of the children in custody — 1,000 — have been with the Border Patrol for longer than 72 hours, and another official said that more than 250 children 12 or younger have been in custody for an average of six days.

Because the crush of migration at the southern border in recent months has overwhelmed U.S. immigration infrastructure, initial incarceration for the tens of thousands of unaccompanied children who have arrived there has averaged four days, the officials said.

“I don’t have any beds, because we’re meant to be short-term processing — not even holding,” one CBP official said of the agency’s facilities here in the Rio Grande Valley, at which some children are sleeping on mats on the floor. “I have stools and benches, but I have no beds. . . . Our facilities are not built for long-term holding, and they’re certainly not built to house children for very long at all.”

The government agencies responsible for the care, transport and sheltering of the unaccompanied children have described a bureaucratic tangle linked largely to the influx of youths, passing the blame for the delays. Because the Border Patrol is the first agency to have them in custody, it has been seeing the backup directly in its stations along the southern border.

Border officials said the immigration system is so overwhelmed that the normal conduits meant to funnel children out of Border Patrol custody and into Department of Health and Human Services shelters have broken down. Migrants are arriving faster than Customs and Border Protection can process them. Immigration and Customs Enforcement typically transfers the children to HHS shelters, but it said the Department of Homeland Security — which oversees ICE and CBP — has been facing “numerous operational challenges,” according to a spokesman.

HHS officials said that the agency is aware that 2,000 children are detained and awaiting transfer and that it has space for them — but they said the agency’s responsibility for the minors begins only once they are delivered to the department’s custody. DHS officials at multiple agencies said HHS is not placing children in shelters fast enough.

Border Patrol has apprehended nearly 45,000 unaccompanied children since October, according to government data. A spokesman for HHS, whose Office of Refugee Resettlement is tasked with providing longer-term shelters for those children, said border authorities had referred approximately 40,800 unaccompanied children to its custody as of the end of April. That marked a 57 percent increase from the previous year, and HHS said it is on pace to care for the largest number of unaccompanied minors in the program’s history this fiscal year.

As of May 19, HHS said there were approximately 13,200 unaccompanied children in its custody.

The U.S. government ranks unaccompanied children as the most vulnerable of the migrants that cross into the United States each year. They are more susceptible to illness, trauma and abuse during and after an arduous journey north from Central America. They pose unique challenges for the U.S. government because of their health and care needs and because they cannot be immediately deported or released.

Following regular protocols, Border Patrol, a law enforcement agency, must quickly process children and then notify the Office of Refugee Resettlement. That agency then designates a shelter placement — sometimes thousands of miles away in places such as New York and Massachusetts. The refu­gee office then coordinates the child’s movement with Border Patrol and ICE.

All of it is meant to happen within 72 hours of a child’s apprehension, barring what U.S. law generally refers to as “extraordinary circumstances.” Instead, a crushing backlog of detainees has turned extraordinary into average.

The backlogs are heaviest here in the Rio Grande Valley — the most-trafficked stretch of border in the nation — where authorities liken their daily operations to a form of triage, regularly transferring children and others from concrete cells to military-grade tents to other stations that have more space.

The McAllen Border Patrol station, a facility near the southern tip of Texas that is routinely overwhelmed, was holding 775 people Tuesday, nearly double its capacity.

The Washington Post this week made a rare visit inside the facility, where adults and their toddler children were packed into concrete holding cells, many of them sleeping head-to-foot on the floor and along the wall-length benches, as they awaited processing at a sparsely staffed circle of computers known as “the bubble.” Hallways and offices previously designated for photocopying and other tasks now held crates and boxes of bread, juice, animal crackers, baby formula and diapers.

One cell held adolescent boys, many of whom stood in the small space, peering out through a glass wall. One stood urinating behind the low wall that obscured the toilet in back. In the adjacent cell, several boys who appeared to be of elementary school age slept curled up on concrete benches, a few clutching Mylar emergency blankets. Outside in the parking lot, a chain-link fence enclosure held dozens of women and children, many of them eschewing the air-conditioned tents to lie on the pavement.

Officials did not allow a visit to the larger central processing center nearby, where they said they try to send all unaccompanied minors upon their arrest and where they remain until they are transferred. There, detainees have access to showers and contractor-provided meals. The processing center was meant to be a stopgap measure when it was constructed to accommodate 1,000 people after the migrant-family spike in 2014, and it has since been extended to accommodate 500 more, said Xavier L. Rios Jr., the deputy patrol agent in charge of the station.

Rios said Border Patrol officials in Texas were often forced to hold unaccompanied children for five to 15 days in 2014, when the federal agencies were less equipped to handle the influx. Attorneys for children held in custody say such extended detentions are a flagrant violation of the law, a 1997 consent decree known as the Flores Settlement Agreement, and CBP guidelines.

Carlos Holguín, a lawyer in the Flores case, said this week that he had never heard of so many children held beyond the limit. He called the trend “disturbing.”

“Children are supposed to be transferred out of those facilities rapidly,” Holguín said. “The system does not seem to be working if it’s taking that long.”

Experts say transferring children out of detention facilities as quickly as possible is critical, especially for “tender age” children — those 12 or younger, who face physical and mental health issues even during short periods in detention. They sleep fitfully, do not eat well and suffer anxiety, said Amy Cohen, a child psychiatrist and expert witness in the Flores case.

“We know their experiences are horrible,” Cohen said. “It’s a very, very scary place. . . . Kids will tell me, even if they’ve been there for two days, they will have flashbacks about it. They have nightmares about it. Children absolutely experience this as a trauma. You can see it in their faces.”

Many also end up with respiratory or other infectious illnesses because they are housed in close quarters. Officials in recent weeks have spotted cases of chickenpox and scabies, moving quickly to isolate the sick from others.

Six children — five from Guatemala and one from El Salvador — have died after being taken into federal custody at the border since September. A teenager who had contracted the flu died last week in the Rio Grande Valley while in Border Patrol custody, leading agents to identify a small-scale flu outbreak.

Border Patrol officials say there are 6,400 people in custody in the Rio Grande Valley, including 931 unaccompanied children. The facilities are so overcrowded that officials say roughly 40 percent of the sector’s 3,100 Border Patrol agents are working on processing new migrant detainees at any given time.

That has left fewer agents out in the vast and wild tangle of brush that stretches for hundreds of miles along the twisting Rio Grande.

Agents on Tuesday morning struggled to pick up and transport more than 170 people — nearly all of them families with small children — that emerged from across the river in the space of an hour.

One group of more than 100 people had crossed in rafts before dawn, and as the sky lightened they sat in the dirt — exhausted parents cradling sleeping babies beneath a cluster of mesquite trees — as a pair of agents collected basic information, instructed them to place the few personal belongings they had carried into plastic bags, and called for transport.

Among the group were five children who had traveled alone, including a 10-year-old boy from Honduras who was wearing an adult’s oversize sweatshirt. He was trying to get to his mother in Lafayette, La., he said, producing from his pocket a folded piece of paper with her phone number on it.

A thin, bleary-eyed 10-year-old from Honduras said she was en route to reunite with her father in Ohio, but she was not sure where. A 16-year-old Guatemalan in rectangular glasses said he was heading to Florida. And a 17-year-old Honduran said he hoped to reach his brother in Houston.

On a dirt road a few miles away, a sole Border Patrol agent was simultaneously running through the same routine with about 30 people, also families and unaccompanied children, also waiting for pickup. And less than a mile from him, a local police officer who had radioed CBP for assistance was standing with 40 more.

“It’s a daily battle,” said one agent who spoke on the condition of anonymity to comment candidly about the work at the border. “You catch a thousand people a day, and then you can only process 750 a day. The agents are working their tails off trying to get this squared away, but it’s a daily struggle with the amount of people we’re encountering.”

Sacchetti reported from Washington.