A federal judge in Tucson, Arizona, has ordered the Border Patrol to improve conditions at its holding facilities in most of the state, saying the agency was not following its own standards by keeping migrants in crowded, cold cells without proper bedding.

Judge David Bury issued the temporary order Friday requiring the Border Patrol's Tucson Sector to provide clean mats and thin blankets to migrants held for longer than 12 hours and to allow them to wash or clean themselves.

Bury said plaintiffs presented persuasive evidence that basic human needs of migrants were not being met.

The case was brought last year by the ACLU, the Morrison and Foerster law firm, and other immigrant rights organizations on behalf of migrants who say the Border Patrol's holding facilities in Arizona are unsanitary, extremely cold and inhumane. Migrants regularly call holding cells "hieleras," the Spanish word for "freezer."

"We believe that the conditions were so below par that when you have people, whether it's two nights or one night sleeping on the floor, that is just below any constitutional standards or norms of decency," ACLU senior counsel Dan Pochoda said.

Bury issued the temporary injunction after a hearing earlier this week at which both parties made arguments.

The Border Patrol has defended its practices and said it's committed to the safety, security and welfare of detainees. The agency did not immediately respond to a request for comment on the order late Friday.

It maintains that it provides migrants with basic human needs in accordance with its own policies, and that agents provide medical care, warmth, sanitation, food and water, and allows detainees to sleep.

But photos released this year after a legal battle by the government to keep them under seal show men jammed together under a thin thermal blanket and a woman using a concrete floor strewn with trash to change a baby's diaper.

Other photos show rusty toilets, dirty toilet paper on the floor and a malfunctioning water fountain in detention areas.

The cells shown in the images are designed to provide short-term shelter for detainees until they can be processed, the agency said. Migrants are usually deported or transferred to the custody of U.S. Immigration and Customs Enforcement, which has long-term detention centers.

NEW MEXICO PROFESSORS SEEKING IMMIGRANT STUDENT PROTECTIONS

The order issued Friday applies to the Tucson Sector's eight facilities and is temporary while the case plays out in court, although Pochoda says it's a good indicator that plaintiffs have the upper hand.

Bury also ordered the Border Patrol to provide medical screening at all times at all stations, monitor cell temperature, ensure that the stations have working sinks and toilets and other materials "sufficient to meet the personal hygiene needs" of migrants, and provide personal products like toilet paper and toothbrushes.

Last year, Bury issued sanctions against the Border Patrol over destruction of surveillance video evidence in the case.

WATCH: IS MEXICO PREPARING TO BATTLE WITH THE TRUMP ADMINISTRATION?

The coalition receives continuous surveillance video from the Border Patrol as ordered by Bury, said Nora Preciado, a staff attorney for the National Immigration Law Center.

The lawsuit was originally filed on behalf of three immigrants but is now a class-action suit.