Updated

Sen. Bob Menendez, a long-time critic of the U.S. system of detaining non-criminal immigrants who have civil violations, is demanding that the Obama administration comply with a federal judge’s recent ruling that says the government is violating a 1997 settlement agreement that governs how and when immigrant children can be detained, and that they should be released.

The New Jersey Democrat said that the hundreds of mothers and children being detained in family detention centers should be freed as soon as possible. The mothers and children were among the tens of thousands who fled violence and poverty in Central America last year, and crossed the Rio Grande in an effort to reach the United States.

Many are seeking political asylum, and have been kept in detention facilities pending a resolution of their case.

“Detention of these families to act as a deterrent was unnecessary,” Menendez said in an interview with Fox News Latino. “They are neither a flight or national security risk. Family detention policies are just inhumane and unnecessary, they’re also illegal.”

“What we want now that the court has ruled is swift enforcement of the court’s ruling,” Menendez said. “The government has to stop unnecessary detention, which is costly and inhumane.”

Menendez also said that detention of immigrants in general must be overhauled to prioritize criminals, not people who have civil immigration violations.

“I’m all for the detention and deportation of criminal aliens,” Menendez said. “But we’re talking about a universe of individuals who are in detention who want to work hard here to sustain themselves and their families and pose no security risk.”

Obama administration officials argue that detention addresses concerns about flight risks, and ensures that people will show up to court for their hearings.

“The bottom line,” Menendez said, “is that there is a way to ensure their appearance at a hearing that doesn’t involve detention. There are monitoring systems, such as ankle bracelets.”

A recent report by the U.S. Conference of Catholic Bishops and The Center for Migration Studies noted that the immigration detention system in this country grew more than five-fold between 1994 and 2013, from 85,000 people annually to 440,557.

“More persons pass through the U.S. immigrant detention system each year than through federal Bureau of Prisons,” the report said.

The ruling last Friday by U.S. District Court Judge Dolly M. Gee says the government has failed to honor a 1997 settlement agreement that governs how and when immigrant children can be detained. It also says the government should release immigrant children from secure family detention facilities and preferably to a parent, even if the parent is also in detention.

In cases where children are held, the judge said the government should ensure the conditions are safe and sanitary and include access to food and water, toilets and sinks and medical and other services.

Peter Schey, who represents the plaintiffs, said he believes 95 percent of children and their mothers who are detained will qualify for release, but he doesn't expect anyone to get out for at least a few more weeks.

The government has until Aug. 3 to tell the court why officials can't comply with the ruling within 90 days, and plaintiffs' lawyers have a week after that to respond.

The government can also decide to appeal the ruling. To prevent it from taking effect, officials would need to seek a stay.

Government lawyers are still reviewing the decision, said Nicole Navas, a Department of Justice spokeswoman.

The Associated Press contributed to this report.