Image copyright Family handout Image caption It is not clear if Rosa Maria Hernandez will be allowed to stay in the US

A 10-year-old undocumented Mexican migrant with cerebral palsy, detained last month after undergoing surgery in Texas, has been released to her family.

The release of Rosa Maria Hernandez was confirmed by the American Civil Liberties Union (ACLU) and Texas Congressman Joaquin Castro.

Her detention, which came after border agents stopped the ambulance taking her to hospital, caused an outcry.

Mr Castro said it was still not clear if she faced deportation from the US.

The ACLU had filed a lawsuit earlier this week seeking the child's release.

"Rosa Maria is finally free," said ACLU lawyer Michael Tan in a statement on Friday.

"We're thrilled that she can go home to heal surrounded by her family's love and support."

He added: "Despite our relief, Border Patrol's decision to target a young girl at a children's hospital remains unconscionable. No child should go through this trauma and we are working to make sure it doesn't happen again."

Media playback is unsupported on your device Media caption Where do America's undocumented immigrants live?

US President Donald Trump pledged a crackdown on illegal immigration, particularly from Mexico, during his campaign. He has vowed to build a wall along the Mexican border.

Mr Castro said the release of Rosa Maria was welcome news, but her future remained uncertain.

"The Trump administration has not made clear whether they will proceed with deportation proceedings against her," he said in a statement.

"I continue to call for Rosa Maria's case to be administratively closed. Moving forward, we must address the Trump administration's callous actions."

US border patrol agents stopped the ambulance carrying Rosa Maria to hospital in Corpus Christi, Texas, for gall bladder surgery 10 days ago.

Agents allowed the ambulance to continue to the hospital under police supervision and armed officers waited near her bedside and detained her when she awoke, family members told US media.

She was then held at an immigration detention centre in San Antonio, Texas, for young migrants.

Her cousin, who had been travelling with her to hospital, told activists that agents had tried to pressure the family to sign documents in order to transfer Rosa Maria to a hospital in Mexico, but this was refused.

Her mother, Felipa de la Cruz, 39, told the New York Times she had brought Rosa Maria to the US seeking better treatment for her cerebral palsy - a neurological disorder that affects body movements.

The family could not afford treatment in Mexico, she said, adding that she hoped Texas would help pay for her daughter's medical care.

"I'm a mother," said Ms de la Cruz, who is also undocumented. "All I wanted was for her to get the surgery that she needed."