A U.S. federal judge ruled Friday that the government must promptly release immigrant children who are being held at family detention centers across the country. The judge said that the children must not be held for over 72 hours unless they pose a "significant flight risk" or are otherwise dangerous to themselves or others, Reuters reported.

District Judge Dolly Gee of the United States District Court in Los Angeles gave President Barack Obama's administration until Oct. 23 to comply with the order that would see hundreds of undocumented immigrant children, and in some cases their mothers, released "without unnecessary delay."

The case concerned a 1997 settlement that set legal requirements for children seeking asylum or residing in the country illegally. Gee ruled in July that the government was in violation of that settlement, and Friday’s order reiterated that.

Last year, over 68,000 children traveling without a parent were found to have illegally entered the country. When they are caught, federal authorities hold unaccompanied children and families with children in special facilities. An estimated 1,400 parents and children are thought to be held at such facilities, according to the Los Angeles Times.

However, Gee said that conditions at these facilities were often “deplorable,” citing cases of children being kept for days in crowded rooms without room to sleep.

The federal government said last month that it was “disappointed” with Gee’s decision and that it was trying to move immigrant children and parents through the system as quickly as possible.

The government is expected to appeal Friday’s ruling, Reuters reported.

The news comes at a time when the immigrant population in the U.S. hit a record high of 42.1 million in the second quarter of 2015, a rise of 1.7 million over the same period last year. Immigrants currently make up 13.3 percent of the country's population, according to the U.S. Census Bureau.

"Illegal immigration came up in the presidential debates, but there has been little discussion of the level of immigration; this at a time when total immigration is surging according to the latest data," Steven Camarota, the center's director of research, said in a statement.