American military officials confirmed that the Islamic State, as well as the Taliban, has now established training camps in Jowzjan Province.

In October, the Justice Department unsealed charges against three Islamic State operatives in a plot for coordinated attacks in New York in summer 2016. Two of the men, according to the charges, said they were working with the Islamic State Khorasan in Afghanistan; one said he received authorization from the Afghanistan group for the planned attacks.

Most of the concerns about safe havens focus on the Islamic State’s move into Afghanistan.

The Islamic State, a successor to Al Qaeda in Iraq, has joined a battle for turf and power among about 20 terrorist groups in Afghanistan, many of them with designs on the West. Together, they make up the highest concentration of extremist groups worldwide among 98 that have been designated as terrorist organizations by the United States or the United Nations, according to Gen. John W. Nicholson, the commander of American and NATO forces in Afghanistan.

Many experts say that General Nicholson’s data may be conflated. Yet no one questions that the number of terrorist groups in Afghanistan has increased sharply in recent years — despite the 17-year presence of American troops.

“The Afghanistan war is almost old enough to vote, and we have more groups that want to launch attacks against the U.S. operating there than we did when we started,” said Caitlin Forrest, an Afghanistan expert with the Institute for the Study of War.

This was not supposed to happen.

Weeks after the Sept. 11 attacks, President George W. Bush sent a small group of Special Operations troops into Afghanistan. Ever since, top officials have repeatedly justified the war as necessary to ensure that Afghanistan never again allows safe haven for groups that targeted American interests.