HOUSTON — A 10-year-old girl with cerebral palsy who entered the United States from Mexico without permission a decade ago is potentially facing deportation after having to go through a Border Patrol checkpoint in South Texas for emergency gallbladder surgery, a family lawyer said Thursday.

Immigration advocates are protesting Rosa Maria Hernandez's case and say Border Patrol should show more discretion in the cases of sick children who are in the U.S. illegally but need medical treatment.

Leticia Gonzalez, an attorney for the Hernandez family, said Thursday that Rosa Maria was taken with a cousin from the Texas border city of Laredo to a children's hospital in Corpus Christi, about 150 miles away. They had to pass through one of several Border Patrol checkpoints set up in South Texas, north of the U.S.-Mexico border.

Gonzalez said Border Patrol agents allowed the girl and her cousin to pass, but followed the hospital vehicle taking them. At the hospital, agents stood by and refused to let Rosa Maria's relative close the door to their room so they could keep watch over the girl, Gonzalez said.

And after the surgery was complete, agents stood ready to escort Rosa Maria to a federal facility for unaccompanied minors in the U.S. illegally, located another 140 miles away in San Antonio.

Rosa Maria is now being held at the facility indefinitely, the attorney said.

Even if she is eventually released to a sponsor approved by the U.S. Department of Health and Human Services, the girl will undergo processing and could be deported. Gonzalez said it could be several weeks before she is released.

"They just refused to allow the child to go home," Gonzalez said Thursday.

In a statement, U.S. Customs and Border Protection confirmed its agents had escorted Rosa Maria from a checkpoint to the hospital.

It said Border Patrol agents were "committed to enforcing the immigration laws of this nation." The statement added that "once medically cleared she will be processed accordingly."

HHS, which oversees facilities for unaccompanied minors in the U.S. illegally, said in a statement that it would not comment on the specific cases of people in its custody.

U.S. Rep. Joaquin Castro, a San Antonio Democrat, blamed the Trump administration for adopting "callous policies" toward immigrants.

Rosa Maria Hernandez, A 10-year-old girl with cerebral palsy, faces deportation. NBC News

"They're treating her like a hardened convict," Castro said.

Gonzalez said Rosa Maria has "difficulty understanding exactly what's taking place" and is closer in development to a child that's 4 or 5 years old.

Her parents are both in the United States illegally and came with Rosa Maria to the U.S. in 2007, when the girl was a newborn, in part to seek better medical treatment for her cerebral palsy. They sent Rosa Maria with a cousin to the hospital because the cousin is a U.S. citizen and could pass through the checkpoint.

The case is reminiscent of a September incident in which a man and woman in the U.S. illegally were followed by Border Patrol to the same Corpus Christi hospital when their newborn child needed surgery.

Astrid Dominguez, immigration policy strategist for the American Civil Liberties Union of Texas, said people without legal status in Texas' border regions have long had to decide whether to seek medical care and face detention, including during the Obama administration.

"This isn't an isolated case," Dominiguez said. "This is a risk they have to take to get medical attention for their children."