The Law of Immigration Detention: A Brief Introduction, October 24, 2019. “The Immigration and Nationality Act (INA) authorizes— and in some cases requires—the Department of Homeland Security (DHS) to detain non-U.S. nationals (aliens) who are subject to removal from the United States. This detention scheme is multifaceted, with rules that turn on several factors, such as whether the alien is seeking admission or has been lawfully admitted into the country; whether the alien has engaged in certain proscribed conduct; and whether the alien has been issued a final order of removal. This In Focus provides a brief introduction to the immigration detention framework..”
For a more detailed discussion (66 page PDF), see CRS Report R45915, Immigration Detention: A Legal Overview, by Hillel R. Smith.