DOHA, QATAR – The nightmare that kept counterterrorism experts awake even before the Taliban returned to power is that Afghanistan would become fertile ground for terrorist groups, most notably al-Qaida and ISIS.

Two explosions claimed by ISIS that killed dozens of people, including at least 13 U.S. service members, in Kabul on Thursday bolstered fears that the nightmare was fast becoming a reality.

"I can't tell you how upsetting and depressing this is," said Saad Mohseni, the owner of Tolo, one of Afghanistan's most popular television channels. "It feels like it's back to business as usual — more bombings, more attacks, except that now we're going to have to deal with it all under a Taliban regime."

Twenty years of military action by the United States and its international partners aimed at stamping out terrorism have exacted major tolls on al-Qaida and ISIS, killing many of their fighters and leaders and largely preventing them from holding territory.

Both groups have proved able to adapt, terrorism experts say, evolving into more diffuse organizations that continually seek out new global trouble spots to take root and put their violent extremism into action.

The twin suicide bombings near the Kabul airport Thursday underscored the devastating power these groups still have to inflict mass casualties despite the American effort. And they raised questions about whether the Taliban can live up to the central promise they made when the Trump administration agreed in early 2020 to withdraw U.S. forces from the country — that Afghanistan would no longer be a staging ground for attacks against the U.S. and its allies.

The Taliban's lightning takeover of the country hardly assures that all militants in Afghanistan are under their control. To the contrary, the ISIS affiliate in Afghanistan — known as Islamic State Khorasan or ISIS-K — is a bitter, albeit much smaller, rival that has carried out dozens of attacks in Afghanistan this year against civilians, officials and the Taliban itself.

In the months before U.S. forces withdrew, about 8,000 to 10,000 jihadi fighters from Central Asia, the North Caucasus region of Russia, Pakistan and the Xinjiang region in western China poured into Afghanistan, a United Nations report said in June. Most are associated with the Taliban or al-Qaida, which are closely linked.

But others are allied with ISIS-K, presenting a major challenge to the stability and security the Taliban promises to provide for the country.

While terrorism experts doubt that ISIS fighters in Afghanistan have the capacity to mount large-scale attacks against the West, many say that ISIS is now more dangerous, in more parts of the world, than al-Qaida.

"It is clear that the Islamic State is the bigger threat, in Iraq and Syria, in Asia or Africa," said Hassan Abu Hanieh, an expert on Islamic movements at the Politics and Society Institute in Amman, Jordan. "It is clear that ISIS is spread more widely and is more attractive to the new generations."

Just Wednesday, American officials warned of specific threats by the group, including that it could send suicide bombers to infiltrate the crowds outside Kabul's Hamid Karzai International Airport.

The threat seems to have been a factor in President Joe Biden's decision to stick to his Aug. 31 deadline to withdraw all U.S. forces from the country.

"Every day we're on the ground is another day we know that ISIS-K is seeking to target the airport and attack both U.S. and allied forces and innocent civilians," Biden said Wednesday.

Created six years ago by disaffected Pakistani Taliban fighters, ISIS-K has vastly increased the pace of its attacks this year, the U.N. report said.

The group's ranks had fallen to about 1,500 to 2,000 fighters, about half that of its peak in 2016 before U.S. airstrikes and Afghan commando raids took a toll, killing many of its leaders.

Since June 2020, the group has been led by an ambitious new commander, Shahab al-Muhajir, who is trying to recruit disaffected Taliban fighters and other militants. ISIS-K "remains active and dangerous," the U.N. report said.

ISIS in Afghanistan has mostly been antagonistic toward the Taliban. At times the two groups have fought for turf, particularly in eastern Afghanistan, and ISIS recently denounced the Taliban's takeover of Afghanistan. Some analysts say that fighters from Taliban networks have even defected to join ISIS in Afghanistan, adding more experienced fighters to its ranks.

The history of ISIS shows how difficult it can be to shut down and contain terrorist networks. The group began after the American invasion of Iraq in 2003 as a branch of al-Qaida, but later broke away, establishing a so-called caliphate — an Islamic theocracy — in large parts of Iraq and Syria that at its peak was the size of Britain.

The group's extremist vision for global expansion, extensive use of social media and cinematic violence drew in fighters from around the world, inspiring deadly attacks in Arab, European and American cities, and spurring the United States to form an international coalition to combat it.

As the United States and its partners bombed the group's main territories, ISIS branched out in other countries. Many of these affiliates have remained active since the group lost its last patch of territory in Syria in March 2019, including in West and Central Africa, the Sinai and South Asia.

Al-Qaida has changed substantially as well since Osama bin Laden oversaw the organization and spread his views via videotaped statements delivered to television stations.

It, too, established affiliates, in Yemen, Iraq, Syria and parts of Africa and Asia, some of which modified, or even discarded, the group's ideology in pursuit of local goals. The group's current leader, Ayman al-Zawahri, is elderly and believed to be ailing and living somewhere in Afghanistan, after failing to match bin Laden's stature among Islamic radicals.

ISIS and al-Qaida remain bitter foes, compete for recruits and financing, and have fought directly against each other, in Afghanistan, Syria and elsewhere.