WARSAW - Afghan President Ashraf Ghani has held Pakistan responsible for failure of the peace initiatives taken by Afghanistan saying Pakistan differentiates between good and bad terrorists "in practice".

Addressing Nato summit on Saturday, Ghani said "Our regional initiatives with neighbours are beginning to yield significant cooperative dividends. However, the exception is with Pakistan."

He went on saying that despite clear commitments to the quadrilateral peace process, Pakistan's dangerous distinction between good and bad terrorists was being maintained in practice.

Ghani said “The key problem among our neighbouring states is an absence of agreed rules of the game, thus we seek regional and global support in creating those rules, which will bind us to collective security and harmony.”

The world leaders should understand that Afghanistan is facing a multi-dimensional conflict and is fighting all sorts of groups "ranging from Al-Qaeda and Daesh to terrorist groups with Central Asian, Chinese, and Russian origins, to Pakistani groups classified as terrorists by Pakistan and the Afghan Taliban groups," Ghani maintained.

Citing the 2015 Makkah declaration against terrorism as an example, Ghani claimed that Afghanistan's dialogue within the Arab-Muslim community was also productive.

Meanwhile, NATO agreed Saturday to maintain troop numbers in Afghanistan and reiterated a funding pledge for local security forces until 2020, but officials did not say when the alliance's longest military engagement might end.

Hundreds of thousands of NATO troops have rotated through Afghanistan since 2001, when the United States ousted the Taliban after the September 11 attacks.

"There's no reason to speculate exactly on how long it will continue," NATO Secretary-General Jens Stoltenberg said at an alliance summit in Warsaw. "What we have seen is we are committed, and we are ready to stay." About 13,000 NATO troops, of which the bulk are American, are currently stationed in Afghanistan under Operation Resolute Support, to train and assist Afghan security forces.

But the Afghans have struggled to contain a resurgent Taliban and have suffered brutal losses - more than 5,000 local police and troops were killed in 2015 and this year is proving as deadly.

Attacks by the Taliban and other organisations like Al-Qaeda and the Islamic State group have meant NATO - especially the United States - has been unable to leave Afghanistan after ending its combat operation at end-2014.

Stoltenberg said NATO will keep thousands of troops in Afghanistan until 2017 under Resolute Support. He did not provide details, but said troop levels would be similar to this year, at around 12,000. "Afghanistan still faces serious instability and violence so our continued political, military and financial engagement is of great importance," Stoltenberg said.

The 28-nation US-led alliance would look at the situation again next year before deciding future force commitments.

The development comes after US President Barack Obama on Wednesday said he was slowing a planned drawdown of US troops from Afghanistan.

Obama had previously vowed to slash troop numbers from the current 9,800 to 5,500 by the end of this year, but on Wednesday said the US would now keep 8,400 in the country.

About 6,700 of these American soldiers will work under the Resolute Support banner - with the rest conducting counter-terrorism operations.

The NATO mission in Afghanistan costs about $5 billion a year, with approximately $3.5 billion coming from the United States.

Stoltenberg said other allies had "nearly" gathered about $1 billion for next year. The remaining funds are due to come from Afghanistan.

In return for its continued support, NATO is demanding reforms of the Afghan security forces, which are grappling with deeply entrenched corruption and human rights issues.

The stakes are high both for Afghanistan and the West.

NATO military head US General Curtis Scaparrotti said failure would turn Afghanistan into a safe haven for groups like Al-Qaeda.

"We will certainly see that impact in our global counter-terrorism campaign," Scaparrotti said. "It will make it harder (and) you can expect that we will see an increased refugee flow out of Afghanistan if we are not successful."

Afghanistan President Ashraf Ghani met US President Barack Obama in Warsaw on Friday. Ghani acknowledged he had much work to do in terms of overhauling his country's institutions and implementing reforms, a US administration official said.

"We need to see greater political unity in Afghanistan, we need to see greater military security and greater self-sustainability by the Afghan security forces which these resources will contribute to," the official said, noting that the only solution for the Afghan conflict is political.

However, efforts to engage with the Taliban are in disarray. The United States in May killed the group's leader, Mullah Akhtar Mansour, in a drone strike in Pakistan.