KABUL — The official government line here is that the Islamic State has been defeated.

The local branch of the extremist Sunni militia, Afghan officials say, has been corralled into a mountainous area near the Pakistani border by Afghan and U.S. forces and can no longer control populated areas. They say it has been reduced to staging suicide attacks against “soft” targets, like the wedding party bombing here on Saturday that killed 63 people and wounded 190. 

“We have eliminated their bases in the east, and they are concentrated in very small areas. They cannot fight our forces face-to-face,” Fawad Aman, a spokesman for the Afghan Defense Ministry, said Tuesday. 

But local leaders in the border provinces of Nangahar and Konar tell a different story. They say Islamic State forces continue to terrorize villagers in areas under their control, forcibly recruiting boys and banning girls from school. They and U.S. officials say that Taliban and Islamic State forces have continued to fight each other, but that they also fear that some Taliban fighters will join the more ruthless Islamic State forces if Taliban leaders make a deal with U.S. officials. 

The United States and the Taliban have been holding talks on an initial agreement for months. The top U.S. negotiator, Zalmay Khalilzad, was expected to arrive in Qatar on Wednesday to prepare for the final round of negotiations after receiving President Trump’s blessing. In the current draft, the deal outlines the initial withdrawal of about 5,000 U.S. troops in exchange for a Taliban pledge to sever ties with al-Qaeda. It also calls for the beginning of Taliban talks with the Afghan government and planning for a cease-fire.

But the agreement does not mention the Islamic State, a sworn enemy of the Taliban that is considered by far the bigger terrorist threat. In a report to Congress last month, the Defense Department said that even if a settlement is reached, al-Qaeda, the Islamic State and some Taliban hard-liners will constitute a “substantial threat” to Afghanistan and the United States, requiring a “robust” counterterrorism capability for the “foreseeable future.”

All three groups are extremist Sunni militias, but they differ in background and behavior. The Taliban is a domestic Afghan movement with deep roots in its society. Al-Qaeda is an international Islamist terror network that has been largely eliminated. The Islamic State is a Middle East-based guerrilla force that seeks to establish a geographic caliphate.

On Sunday, Khalilzad said in a tweet that success in the talks “will put Afghans in a much stronger position to defeat ISIS.” U.S. officials believe that the Taliban, already battling the Islamic State, can be a force multiplier for U.S. counterterrorism efforts against the group.

The Islamic State in Afghanistan is estimated to number between 2,500 and 5,000 fighters, according to figures from the U.S. military and the United Nations. The U.S. military estimated that the total was around 1,000 active fighters in 2017. But there is widespread concern here that those numbers could rise even more if the Islamic State uses a U.S.-Taliban agreement to siphon off hard-line Taliban fighters who are opposed to the deal and ramp up its terror war.

The Islamic State is “trying to position itself as being able to reap the benefit of any fissures in the Taliban after a peace deal,” said one Western official, speaking on the condition of anonymity because he was not authorized to discuss the matter. He said the group had posted messages criticizing the Taliban for “negotiating with the enemy.” 

Asked Tuesday if the militants were gaining strength, Secretary of State Mike Pompeo noted that the Islamic State’s self-declared caliphate, centered in Iraq and Syria, was gone. But, he said in a CBS interview that comported with Defense Department comments about Afghanistan, “there are certainly places where ISIS is more powerful today than they were three or four years ago.”

The Taliban, with up to 80,000 fighters, far outnumbers Islamic State forces here, the Western official said, “but ISIS is more relentless. The Taliban still think they are going after legitimate targets. For ISIS, anyone is fair game. They can do a lot of devastation with single actors, as we saw with the wedding attack. They’ve been recruiting young Sunni men in Afghan universities, and looking for those who can cross borders more easily to fight abroad. That’s one reason to keep a counterterror force in the country.”

Among those making that argument is David Petraeus, a former top U.S. military commander in Afghanistan. He argued in an op-ed piece this month, co-written with Vance Serchuk of the Center for a New American ­Security, that “the cost of retaining a few thousand troops in Afghanistan pales in comparison with the price the nation will pay, strategically and economically, if al-Qaeda or ISIS rebuilds a terrorist platform there.”

In Kabul, especially in the minority Shiite and ethnic Hazara community where the Islamic State claimed the recent wedding attack and scores of suicide bombings in the past several years, community leaders say they expect such attacks to become worse after a Taliban peace agreement, as the Islamic State flexes its religious and military muscle with both U.S. forces and former Taliban enemies no longer in the fighting business. 

“Even after a peace deal is signed, Daesh attacks will continue and Taliban hard-liners will join them,” said Chaman Ali Behsodi, a municipal representative in a Hazara district near the site of the wedding attack. The local branch of the militant group in Afghanistan calls itself the Islamic State in Khorasan but is known to Afghans by its Arabic name Daesh. 

He said a female Islamic State suicide bomber blew up a voter registration center in the district last year, killing 60 people. “We are asking the government to give us arms, because they cannot protect us.”

Zulfiqar Omid, a Hazara activist in Kabul, said the Islamic State and other terrorist groups will continue to target his community no matter what becomes of the Taliban. Many analysts ascribe the Islamic State’s motives to religious hatred for Shiites, but Omid said Hazaras are targeted because they are “pro-election, pro-education and pro-women’s rights.” The terrorists, he said, “want to create panic in our community, by creating horror in mosques, schools, sports gyms and now wedding halls.”

The Islamic State entered the Afghan conflict in 2014 as an offshoot of tribal extremist groups in Pakistan. It was not seen initially as a major threat, but as its numbers have grown, the group has tried to seize territory in four provinces, recruited students and staged scores of suicide bombings. 

Since being defeated in Iraq and Syria, the group has begun urging idle foreign fighters to join a holy war in Afghanistan. It has gained substantial income from local minerals, lumber and other natural resources, and it also practices extortion and kidnaps people for ransom, according to a U.N. report.

U.S. military officials have been targeting the Islamic State in Afghanistan for several years, conducting counterterrorism missions with Afghan special operations forces and with support from drone attacks. U.S. military officials claim to have pushed back the militants to the rugged Spin Ghar mountains, but the group has claimed dozens of urban bombings in the past four years that have killed hundreds of people.

Attacks attributed to the Islamic State killed or wounded 423 of 3,812 total civilian casualties in the first half of this year, according to a report issued recently by the U.N. Assistance Mission in Afghanistan. 

In parts of rural eastern Afghanistan, meanwhile, several officials this week described the Islamic State as having been circumscribed but not defeated. Ataullah Khogiani, spokesman for the Nangahar governor, said that the militants’ influence was declining and they could not capture new areas, but that “they still have a presence. They and the Taliban fight and kill each other, but we don’t know who has the upper hand.”

Salim Mohammed Salim, a former legislator in Konar province, said the Islamic State had established bases in his region, forced villagers to flee, recruited some men by force and killed others who resisted. 

“They are dug in these rugged areas, and nobody can dislodge them,” Salim said. “The Taliban tried and failed. The Americans used to send drones, but they stopped. The Afghan government is incompetent.” He said that the Taliban is more lenient and accepts local tribal decisions, but that Islamic State leaders cover their faces and are “heavy-handed. They don’t listen. They just force.”

The former lawmaker said ­Afghans had been through “a ­bitter experience” when former ­anti-Soviet fighters felt left out of power and turned into warring factions, causing a destructive ­civil war. This time, he said, “if there is no comprehensive peace agreement that offers the Taliban jobs, reintegration into society and a place in power, some of them will join Daesh, and the war will go on.”

DeYoung reported from Washington. Sayed Salahuddin and Sharif Hassan in Kabul contributed to this report.