(Reuters) - A 10-year-old Mexican girl with cerebral palsy living illegally in Texas was in federal custody on Thursday after the ambulance rushing her to surgery had to pass through a U.S. Border Patrol checkpoint, a family attorney and government officials said.

Rosa Maria Hernandez was being transported from a medical center in Laredo, on the border with Mexico where the girl lives with her family, to a hospital in Corpus Christi, about 130 miles (210 km) away, for emergency gall bladder surgery early on Tuesday.

Her ambulance had to pass through one of the dozens of U.S. Customs and Border Patrol checkpoints set up on highways close to the Mexico border. Hernandez was accompanied by a cousin who is a U.S. citizen, according to Leticia Gonzalez, a lawyer for the girl’s family.

The border agents allowed her to proceed to the hospital but her detention after the surgery has been criticized by opponents of U.S. President Donald Trump’s crackdown on illegal immigration, which was a major part of his election campaign last year.

“They aren’t prioritizing criminals and people who are national security threats; they’re going after children,” U.S. Congressman Joaquin Castro of Texas told reporters on a conference call. He accused immigration officials of violating their own “sensitive locations” guidelines, which advises against detaining people at hospitals, schools and houses of worship.

Several border agents waited outside Hernandez’s hospital room while she recovered for a few hours from surgery on Tuesday before driving her to be detained at a federal shelter in San Antonio, Texas, the family’s lawyer, who was at the hospital, said.

U.S. Customs and Border Patrol released a statement saying its agents were enforcing the law.

“Per the immigration laws of the United States, once medically cleared she will be processed accordingly,” the statement said.

Gonzalez, the family’s lawyer, told reporters the government was ignoring advice from the girl’s surgeon that she should stay with family members who were familiar with her disabilities and that she must see her doctor in Laredo within three days.

She criticized immigration officials who declined to use their discretion to release the girl into the care of her cousin, a U.S. citizen, or her grandfather, a legal permanent resident.

The girl’s mother, Felipa De La Cruz, said she brought her family illegally to Laredo when the girl was three months old, seeking better opportunities and medical care.