In late November 2001, after the United States invasion of Afghanistan, Hamdi was captured by Afghan Northern Alliance forces in Kunduz, Afghanistan, along with hundreds of surrendering Taliban fighters. All the men were sent to the Qala-e-Jangi prison complex near Mazar-i-Sharif.