Immigrant children being detained in a Texas hotel are getting a reprieve from being deported and will be given a chance to stay in the U.S.

The Trump administration, through an emergency declaration issued on Monday, has agreed not to remove a group of immigrant children it detained citing the coronavirus and will instead allow them to seek to remain in the U.S.

A Hampton Inn is shown Tuesday, July 21, 2020 in Phoenix. (AP Photo/Matt York)

This comes after the Associated Press first reported on the U.S. government's secretive practice of detaining unaccompanied children in hotels before rapidly deporting them during the virus pandemic.

The U.S. had detained children nearly 200 times over two months in three Hampton Inn & Suites hotels in Arizona and two Texas border cities, according to data obtained by the AP.

The agreement only covers 17 people known to have been detained as of Thursday at the Hampton Inn in McAllen.

The Trump administration has not said it will stop using hotels to detain children.

The legal groups that sued Friday night plans to challenge the overall practice in court.

“The children in this hotel averted disaster only because we happened to hear about them before they were deported, yet hundreds if not thousands of other children are being sent back to harm in secret," said Lee Gelernt, a lawyer for the American Civil Liberties Union. "The government must stop expelling children in secret without giving them asylum hearings.”

A Hampton Inn is shown Tuesday, July 21, 2020 in Phoenix. (AP Photo/Matt York)

The children will be transferred by immigration authorities to shelters operated by the U.S. Department of Health and Human Services, where they will have access to lawyers and can pursue asylum cases or other immigration relief to try to remain in the country.

CLICK HERE TO GET THE FOX NEWS APP

A spokeswoman for Hilton, which owns the Hampton Inn brand, said franchisees owned all three Hampton Inns and the others in Phoenix and El Paso, Texas, would also stop child detention in its hotels. Hilton said in a statement that the company expected all of its franchisees “to reject business that would use a hotel in this way.”

The Associated Press contributed to this article.