"Leaving Afghanistan in my judgment would give the terrorist groups the space with which to conduct operations against the American homeland and its allies," Dunford told a meeting at the Washington Post newspaper on Thursday.
"It is our assessment that in a period of time… [the terror groups] would have in the future the capability to do what they did on 9/11," he said.
Almost 3,000 people were killed on September 11, 2001 when al-Qaeda hijacked four US airliners and flew two of them into the Twin Towers of the World Trade Center and a third one into the Pentagon building in northern Virginia.
READ MORE: US Dropped More Bombs on Afghanistan in 2018 Than Ever in Recorded History
Continued US and allied commitment had supported the emergence of an Afghan-led reconciliation process with the Taliban guerrilla forces in the country, Dunford said.