Al-Qaida has re-established a presence in Afghanistan and the Islamic State group has become a serious threat, the Afghan national security adviser warned, saying the country was in danger of again becoming a safe haven for terrorists and calling for U.S. and NATO military backing to help drive them out.

The warning by Mohammad Hanif Atmar follows the announcement earlier this month by President Barack Obama that the U.S. would keep 9,800 troops in Afghanistan through most of next year, casting aside a pledge to withdraw most U.S. forces before leaving office. Obama cited the fragile security situation in the face of a resurgent Taliban.

Speaking to The Associated Press in an interview late Saturday, Atmar said al-Qaida, the Taliban, the Islamic State group and other insurgents, including the brutal Haqqani network, which has ties to the Taliban, "are morphing."

"They have not been degraded, they have regenerated themselves," he said.

Atmar warned the insurgent groups are reinventing themselves, joining forces, and drawing funds and support from outside as they take advantage of a perceived weakness of Afghan forces following the end of the U.S.-led international combat mission last year.

Highlighting Afghanistan's need for continued support from the U.S. and NATO, the Taliban overran the key northern city of Kunduz on Sept. 28 — their first seizure of a major urban area since being toppled in 2001 by the U.S. invasion — before being driven out over a period of two weeks. The Taliban then threatened cities in different corners of the country, including Lashkar Gah, capital of southern Helmand province, and Maymana, capital of northwestern Faryab.

The Taliban have been stretching Afghan forces to the limit this year, and the shift in tactics — from scattered shootings and bombings to coordinated assaults on cities — has posed a challenge to a force accustomed to coming in behind U.S. troops to hold territory, rather than going on the offensive.

This has provided fertile ground for insurgent groups to move into Afghanistan from other countries, particularly Pakistan, where a military campaign to eliminate their safe havens from the tribal areas of North Waziristan has pushed militants into Afghanistan.

Atmar said several groups are now using Afghanistan as a staging ground to reach their "home countries," including China, Uzbekistan and other Central Asian states, and Russia.

"What needs to be well understood is that the symbiotic network of terrorists that we are confronted with is going to be a threat to every country in this region and by extension the whole world," Atmar said.

"We are hoping that assessment is shared not just by Central Asia, Russia and China, but by our neighbors to the south and east," he said, referring principally to Pakistan.

Al-Qaida has made a return to Afghanistan since the drawdown of U.S. and NATO troops began picking up steam from 2011 to 2013, Atmar said, blaming the simultaneous withdrawal of intelligence and eye-in-the-sky technology that the international forces had provided.

He said the Islamic State group now poses an "existential threat" because it no longer includes only disaffected Taliban, unhappy with the lack of progress after years of fighting to topple the Kabul government, but has an "institutional connection" to the group's leadership in Iraq and Syria.

Leaders are now being appointed directly by the IS leader Abu Bakr al-Baghdadi, Atmar said, entrenching the rivalry with the Taliban — which believes itself the rightful ruler of an Afghan Islamic state.

"They have well-established connections to the Islamic State (in Syria and Iraq). Islamic State is commanding and controlling them, Islamic State is financing them, Islamic State is giving them the strategy to pursue. We have no doubt about that," he said.

IS loyalists have a foothold in eastern Nangarhar province, near the Pakistan border, where they have battled government forces and Taliban fighters. Atmar said military operations were underway to dislodge IS from the four districts they have seized.

"What these groups need to survive and to grow is sanctuaries, whether in Pakistan or Afghanistan. They've had them in Pakistan for decades now," Atmar said, referring to the widespread belief that Pakistani authorities provide safe haven to Taliban leaders.

"Unless we get rid of the Taliban, either through counter-terrorism or through peace and reconciliation, these elements will grow because they need a host, and they need a recruitment facility. And we should not allow the Afghan Taliban to grow into that kind of facility for them," he said.

As the Taliban's traditional fighting season draws to a close, before winter snows cut mountain routes to and from Pakistan, Atmar said he expected another tough fight in 2016.

"Our principle assumption is that the Taliban are not interested in peace," he said. "Those who believe the Taliban can win militarily need to be convinced they are wrong."

Atmar called on Pakistani authorities to use their influence on the Taliban. Pakistan hosted a first round of peace talks between the Taliban and the Afghan government earlier this year, but the process was postponed indefinitely after the announcement of the death of Taliban founder Mullah Mohammad Omar.

Atmar said that before the process could be revived, the Afghan government hoped for talks with the Pakistani leadership.

"We hope that the response is reciprocal, that they are seeing the opportunity that has risen for a genuine peace and reconciliation between the two states and then between the government of Afghanistan and the Taliban," he said. "Our position is that we cannot go to the negotiating table while they (the Taliban) are killing our children."