The detainees were illegal immigrants, with several having criminal histories, gang affiliations, or ordered to be removed from the U.S. by a federal judge.