The man is “an extreme danger to the community and to anyone who may want to take him in,” one prosecutor said.