With the Taliban's return to power in Afghanistan, international terrorism is a threat and NATO "needs to stay vigilant to stay at the forefront of the fight" against it, says the head of the alliance.
As coalition troops withdraw, Jens Stoltenberg said NATO will remain on alert for signs that terrorist groups are regrouping in Afghanistan and could strike them from a distance if they try to re-establish themselves there.
The 9/11 al Qaeda attacks on the US were organised from Afghanistan by Osama bin Laden's terror group which had been given a safe haven by the Taliban when they previously were in control from 1996 to 2001.
That was the pretext for the US-led invasion 20 years ago which ousted the Taliban.
Mr Stoltenberg, the secretary general, told reporters at a news conference in Brussels: "Those now taking power have the responsibility to ensure that international terrorists do not regain a foothold."
In emotional scenes during the news conference, a tearful Afghan journalist, Lailuma Sadid from Brussels Morning, questioned how NATO and EU with their "big intelligence" were not able to defend against "only a group of Taliban" when they had beaten the likes of Nazism and imperialism in the past.
And she pleaded with the NATO chief not to recognise the Emirate Islamic Taliban without any conditions, after the last time it was in power it stopped girls going to school and banned women from working.
He said: "It was extremely difficult to make the decision to end the NATO mission presence in Afghanistan. I share your pain. I understand your frustration.
"We will continue to hold the new rulers accountable for upholding fundamental human rights, including the rights of women. It is a tragedy what we now see taking place in Afghanistan.
"There have been gains and we need to make all efforts to preserve those gains including the fact that generations of men and women are now educated and are taking part in political processes. It will not be easy for new rulers to take away all those gains."
It comes as a Taliban spokesman told Sky News that women in Afghanistan will have the right to work and be educated up to university level.
Suhail Shaheen said "thousands" of schools continue to operate, following the Taliban takeover.
Women will be expected to wear the hijab, but not the burka, he said, adding: "These are not our rules, these are Islamic rules".
NATO, made up of countries from Europe and North America, has been leading international security efforts in Afghanistan since 2003 but wound up combat operations in 2014 to focus on training the national security forces.
Mr Stoltenberg blamed the fall of the country to the Taliban on the Afghan government "which failed to stand up" to the militants.
He said: "Part of the Afghan security forces fought bravely.
"But they were unable to secure the country, because ultimately the Afghan political leadership failed to stand up to the Taliban and to achieve the peaceful solution that Afghans desperately wanted."
Referring to the way that the Afghan armed forces withered in the face of the Taliban offensive, Mr Stoltenberg said that "was a surprise, the speed of the collapse and how quickly that happened".
He said "there are lessons that need to be learned" at NATO.
He added NATO and its allies had the "capacity and vigilance to address future terrorist threats from Afghanistan".
The alliance's aim in Afghanistan was to help build a viable state, not to maintain a permanent presence there, and so the government's collapse in the face of Taliban forces after 20 years was a tragedy, he continued.
He said about 800 civilian personnel from NATO countries have remained behind in Afghanistan to help, notably in keeping the Kabul airport running, including staff to run air traffic control, aircraft fuelling operations and communications.
Mr Stoltenberg also urged the Taliban to respect the wishes of those who want to leave and not to close border crossing points or airports.