Last spring, as Central American children flooded into Texas in a way he had never seen in his three-decade career, Border Patrol agent Robert Harris decided to experiment.

His intelligence analysts estimated that 78 percent of the guides smuggling other migrants were Mexicans younger than 18 — teenagers often hired or conscripted by drug cartels that knew they would not be prosecuted if caught — and he wanted to attack this loophole.

“Why don’t we remove these juveniles from the smuggling cycle?” Harris, the outgoing commander of the Laredo sector of U.S. Customs and Border Protection, recalled thinking.

Now, as a result of that decision, young Mexicans are being held for months without charge in shelters across the United States, sometimes without their parents’ knowledge. Since the program began in May, 536 juveniles have been held — 248 of whom have been deported to Mexico after an average stay of 75 days, according to Border Patrol statistics. Mexican authorities say some of these repeat border-crossers have spent as much as six months in U.S. custody while they await an appearance before an immigration judge.

During their detention, they are questioned by U.S. authorities and then transferred to a network of facilities run by the Office of Refugee Resettlement, part of the Department of Health and Human Services, across 15 states. While confined, they undergo psychological evaluations and take English courses. Some are allowed tourist-type activities, such as going to the beach or museums, according to Mexican consular officials in Texas. At least one youth earned a high school general equivalency diploma.

Two U.S. Border Patrol agents patrol the banks of the Rio Grande on Feb. 12 in Laredo, Tex. (Jonathan Levinson/For the Washington Post)

“We haven’t heard of any mistreatment,” said Erasmo R. Martinez, Mexico’s consul in McAllen, Tex.

But the little-known program, called the Juvenile Referral Process, has worried human rights groups and some Mexican officials who fear that it puts the children at risk. They view it as a way for U.S. authorities to gather intelligence about cartels and think it endangers the children who could be targeted as informants when they return to Mexico. Some question the legality of the extended detentions.

“Our concern is that the program’s real intent is to interrogate the kids,” said Maureen Meyer, an expert on Mexico and migrants at the Washington Office on Latin America (WOLA). The kids are “often questioned about the criminal groups they are working for and then subsequently returned to Mexico with no apparent concern about the implications for them.”

While in custody last year, one Mexican boy who worked as a guide shared information with U.S. authorities about the location of stash houses used by migrants as they move through the United States, according to his lawyer’s written summary of his case. When he returned to Mexico, he learned that armed men had forced their way into his home and killed a relative’s son. The men told the family that there had been raids on cartel hideouts and arrests and that they believed the boy was responsible. His half-brother was later killed by the same group. The boy, his lawyer said, has since been in hiding.

Harris said the Border Patrol does not have a system to track what happens to the juveniles once they return to Mexico. The program does appear to be discouraging them from returning illegally to Texas, he said. The patrol calculates that just 7 percent of the children who have gone through the program have been picked up again crossing the border.

In the past, Mexican minors picked up by the Border Patrol normally would be deported by bus, sometimes on the same day they arrived. Some of these kids have been captured more than 60 times, and Harris’s officers have identified about 800 young smugglers operating in Texas. Human rights workers in Mexico and the United States say these kids are often forced to work for the cartels or risk retaliation against themselves or their families.

Drug cartels “exploit hundreds of juveniles, using them as smugglers, guides, and scouts; in turn these juveniles are responsible for smuggling thousands of illegal aliens and large amounts of narcotics,” the Border Patrol told WOLA in a statement about the program.

The program began in May in two Border Patrol sectors, Laredo and Del Rio, consisting of nearly 400 miles of the Texas border with Mexico.

“The moment it started, it took us all by surprise, because there wasn’t an announcement,” said Reyna Torres Mendívil, director general of the Mexican Foreign Ministry’s office for protection of Mexicans abroad. “Where were they taking these children?”

Border Patrol agents would refer them to the U.S. attorney’s office, but typically, unless there are aggravating circumstances, they won’t be prosecuted. So this period of detention is intended to be a punishment in lieu of a criminal charge. The shelters they are sent to also house juveniles from Central America, awaiting flights home; last year, the Mexican kids accounted for about 1 percent of all the detainees in these facilities.

In November, Oscar Jaime Rodriguez Mendoza, a 16-year-old from the border town of Reynosa, left for the United States and didn’t come home.

“We didn’t know what had happened to him,” said his mother, Leonor Mendoza, a 37-year-old clothing vendor.

She finally learned that he had been sent to a shelter in California. From there, he was allowed to talk to her by phone every night for 10 minutes. Oscar told his mother that the kids were grouped by risk or behavior — purple, yellow, green — and that some couldn’t leave the facility. Oscar was a purple, he told his mom, with the least restrictions. On one occasion, he got to go ice skating.

“It’s a type of punishment so they won’t cross as much,” his mother said. “For me, sincerely, it’s okay. It will discourage him from doing it again.”

Mexican authorities say they don’t want these minors to be stigmatized or criminalized by U.S. authorities. Mendívil, of the Foreign Ministry, said that not all repeat border-crossers are cartel-linked smugglers. She cited the case of one child who crossed repeatedly to buy used clothes for his mother to sell in Mexico.

“We’re in favor of what is in the best interest of the minor,” she said. “Many of these kids may have legitimate claim to perhaps be reunited with family in the U.S. We want them to have their day in court and be heard. If they are threatened, if they are victims of trafficking, if they have been in a family crisis situation, they deserve to be heard and protected from whatever is threatening them.”

At the local level, Mexican immigration officials along the border consider the program effective because they’ve found that it discourages children from working as guides.

“It’s excellent for us,” said Erasmo Rodriguez, an immigration official in the border town of Piedras Negras. “We’ve received many fewer minors.”

In the first two months of the year, just five repeat crossers from the area were deported to his office. Before the Border Patrol program, he said, dozens would be returned in a normal month.

Gabriela Martinez in Mexico City contributed to this report.

Central American migrants overwhelm Border Patrol station in Texas

Charles Bowden, author of probing, lyrical accounts of the Southwest, dies

Guatemalan president: At least $2 billion needed to address immigration

Migrant kids in U.S. custody are flown thousands of miles at taxpayer expense