WASHINGTON — Senior United States military and intelligence officials are sharply divided over how much of a threat the Islamic State in Afghanistan poses to the West, a critical point in the Trump administration’s debate over whether American troops stay or withdraw after nearly 18 years of war.

American military commanders in Afghanistan have described the Islamic State affiliate there as a growing problem that is capable of inspiring and directing attacks in Western countries, including the United States.

But intelligence officials in Washington disagree, arguing the group is mostly incapable of exporting terrorism worldwide. The officials believe that the Islamic State in Afghanistan, known as Islamic State Khorasan, remains a regional problem and is more of a threat to the Taliban than to the West.

Differences between the American military and Washington’s intelligence community over Afghanistan are almost as enduring as the war itself. The Pentagon and spy agencies have long differed over the strength of the Taliban and the effectiveness of the military’s campaign in Afghanistan.