KABUL—Undercover Taliban agents—often clean up-shaven, dressed in jeans and sporting sunglasses—spent yrs infiltrating Afghan government ministries, universities, businesses and assist businesses.

Then, as U.S. forces were being completing their withdrawal in August, these operatives stepped out of the shadows in Kabul and other significant towns across Afghanistan, shocking their neighbors and colleagues. Pulling their weapons from hiding, they aided the Taliban swiftly seize handle from the within.