A Costa Rican judge on Monday ordered the closure of an overcrowded, disease-infested prison he condemned as a "human cage."
Judge Roy Murillo found conditions were so bad in the San Sebastian prison that locking people up there amounted to "state terror incompatible with a democracy."
The 35-year-old prison in the capital, San Jose, was built to hold 559 inmates, but currently has 1,278 - most of them suspects awaiting trial.
The judge found that in some areas up to 25 prisoners were sharing a single toilet, creating "uncomfortable and degrading conditions."
Prisoners often sleep on the floor in a space as small as one square metre (11 square feet), with insufficient light and ventilation, he said.
Overcrowding and poor sanitation have caused outbreaks of flu, allergies and skin diseases, investigators found.
The judge ordered the justice ministry to close the "giant dungeon" within 18 months.
Latin America`s prisons are plagued by overcrowding, gangs and violence.
Costa Rica`s hold around 14,000 inmates, well over their total capacity of 9,000.
Justice Minister Cecilia Sanchez has launched a program to reduce the prison population by paroling 1,400 inmates convicted of minor offenses.
But the move has stoked controversy, with opponents accusing President Luis Guillermo Solis`s government of setting dangerous criminals loose.