Washington (CNN) A federal judge in Arizona ruled Wednesday that conditions in US Customs and Border Protection migrant holding cells in the agency's Tucson sector violated the Constitution.

US District Judge David C. Bury's order bars the agency from holding migrants for more than 48 hours in the Tucson sector after they've been processed "unless and until CBP can provide conditions of confinement that meet detainees' basic human needs for sleeping in a bed with a blanket, a shower, food that meets acceptable dietary standards, potable water, and medical assessment performed by a medical professional."

The lawsuit over conditions in the Tucson sector was first filed in 2015. Bury's decision comes after a January trial in which lawyers representing migrants presented images that they said showed dangerous overcrowding in CBP facilities.

In his ruling, Bury cited those conditions as he banned the use of bathrooms for sleeping, calling it "unsanitary and degrading."

"Being forced to sleep in a toilet area due to overcrowding offends the notions of common decency; it is unsanitary and degrading for all detainees who either have to sleep in the toilet area or try to use the toilet when others are sleeping there," he wrote.

Read More