KABUL—A veteran of the U.S. military’s most elite and secretive combat units took command of American and NATO forces in Afghanistan on Sunday, citing the danger posed by terrorist sanctuaries here to explain why the 17-year mission must continue.

Gen. Austin “Scott” Miller, who was among the first American soldiers to enter Afghanistan after the Sept. 11, 2001, terrorist attacks on New York and Washington, assumed command of about 14,000 U.S. forces and 8,000 military personnel from other countries.

“The...