ISLAMABAD — The Islamic State group and the Taliban are competing to take credit for a horrific spike in violence in Afghanistan over the last month, and analysts say both insurgent groups are growing in strength as security forces wither under their relentless attacks and a feuding government struggles to win over citizens.

Still, the two insurgent groups embrace different agendas and are at war with each other as well as the Afghan government, analysts say.

Recent large-scale attacks, which have included both suicide bombings and small arms fire, have left nearly 200 people dead and hundreds more wounded. Insurgents have targeted seemingly heavily secure areas in the heart of the Afghan capital, including an Afghan military academy on Monday and a hotel, owned by the government and frequented by foreigners, earlier this month. Using an ambulance to hide their deadly cargo, insurgents slipped passed checkpoints in Kabul’s heavily fortified center on Saturday to kill more than 100 people. They also targeted an international aid organization in eastern Jalalabad and a Shiite cultural center in Kabul.

Afghan Security Forces seem powerless against the onslaught.

Insurgents share the same goal of delegitimizing the governments they are fighting against, said Andrew Wilder, vice president of Asia programs at the U.S. Institute of Peace. However, in Afghanistan the similarity between IS and the Taliban ends there. Beyond toppling the Afghan government, the Islamic State affiliate and the Taliban have divergent goals, and where the Taliban are seen as possible negotiation partners in a search for peace, the ISIS is not.

The two groups have occasionally clashed on the battlefield.

“The Taliban and IS are clearly competitors in the Afghan arena,” said Thomas Ruttig, whose Afghan Analysts network has deep knowledge of the country and has conducted nationwide studies into a myriad of issues confounding the country, including ISIS and Taliban.

“The Taliban I see as ‘national Islamists’ while the IS is ‘Internationalist,’” he said, dismissing reports of collaboration between the two insurgent groups, attributing them to rumors and bickering in northern Afghanistan within the Taliban.

Ruttig said Taliban fighters in northern Afghanistan recently flew the ISIS flag after the Taliban leadership ordered them to hand over their tax collection revenue to the governing Taliban shura or council. A major source of revenue for the Taliban is the tax or tolls they charge local residents for safe passage or to move legal as well as illegal commodities to market.

“The groups in the north are a separate phenomenon. There, Taliban commanders have switched to use IS insignia, but the trigger was conflict over transferring taxes to the central leadership,” said Ruttig.

Brian Glyn Williams, author of “Counter Jihad, The American Military Experience in Afghanistan, Iraq and Syria,” buttressed reports of the enmity that characterizes the Taliban/IS relationship, saying, “their relationship is more defined by open warfare.”

While loosely constructed, the Taliban since the death of its supreme leader Mullah Mohammed Omar several years ago are mostly comprised of ethnic Pashtuns and Arab speaking nationals with ties to al-Qaida.

The strongest fighting force within the Taliban is the Haqqani network, which has been blamed for the most audacious attacks in Kabul. The Haqqani network has historical ties to Pakistan’s powerful ISI spy agency and both the United States and Afghanistan accuse Pakistan of providing sanctuary for Taliban fighters, a claim Islamabad denies. Pakistan in turn has blamed some of the most horrific attacks in Pakistan on ISIS affiliate insurgents in Afghanistan, accusing Kabul of allowing them space to plot their attacks.

Meanwhile, the ISIS affiliate known as IS in Khorasan Province, named for the ancient region that once included Afghanistan, parts of Iran and Central Asia, is a toxic mix of disgruntled Taliban, ferocious Pakistani Taliban, who have sworn allegiance to ISIS against Pakistan, as well as Uzbeks, mostly from the Islamic movement of Uzbekistan terror group.

The success of the U.S. and its allies in driving Islamic State fighters out of Iraq and Syria has pushed many toward Afghanistan, said Williams. Bolstering their ranks, he said, is Afghanistan’s own Uzbek population living in northern Afghanistan, who have been drifting toward the ISIS affiliate as a protracted feud between President Ashraf Ghani and his vice president and Uzbek warlord, Rashid Dostum deepens.

Dostum has been living in Turkey since last year when he and his bodyguards were accused of kidnapping and sexually assaulting Ahmad Eshchi, a former ally turned enemy. Ghani prevented Dostum’s return to Afghanistan, refusing to allow his plane to land in northern Mazar-e-Sharif. Dostum’s absence as a strongman for Afghanistan’s Uzbeks has prompted many to join ISIS, said Williams.

He said as many as 3,000 Afghan Uzbeks may have joined the ISIS affiliate already believed to have several thousand Uzbeks from central Asia.

The role of Afghanistan’s neighbors further muddies the insurgent landscape, say those familiar with the region.

Pakistan, widely blamed for the Taliban’s longevity as a fighting force, is aided by both Russia and Iran, who fear an ISIS stronghold in Afghanistan.

“Pakistan has a deep interest in ensuring that the Taliban doesn’t partner with (the Islamic State group),” said Michael Kugelman, deputy director of the Asia Program at the U.S.-based Wilson Center. “There’s good reason to believe that Russia and also Iran have provided levels of support to the Taliban.”

“The last thing Russia and Iran want are a resurgent (ISIS) in their broader backyard,” he said.