Pakistan’s national security adviser has suggested the West faces another 9/11 if it abandons Afghanistan for a second time.

Dr Moeed Yusuf issued the stark warning as the international coalition struggles to get its remaining troops out of the country, after an ignominious defeat to the Taliban.

Abandoning the country could also cause a mass wave of refugees, Dr Yusuf told Sky News.

When the Soviets withdrew in 1989 the West turned its back on the region, he said, and allowed it to become a safe haven for terrorists.

Pakistan has not yet recognised the Taliban but is urging the international community to “engage” to avoid a security vacuum.

Dr Yusuf said now is the time for the world to listen and come together to avoid the mistakes of the past.

“If there’s no money in Afghanistan, if there’s no governance, if ISIS-K and al Qaeda and others take root, what do you think will happen?

“And by the way let me also tell you, this will not be constrained to the region. I read somewhere, I think one statement came out, that the migration problem should be limited to the region, it won’t.

“Migrants will flow, terrorism will flow and none of us want that so let’s not make that mistake again.

“The dangers of abandonment, which came about in the 1990s, there was a breakdown of law and order, there was a breakdown of security, there were international terrorists who took route, there was an economic crisis, there was a governance problem and at the end of the day there was 911.”

There hasn’t yet been a huge flood of refugees out of the country, but hundreds of thousands have been internally displaced and the dangers are already there for that humanitarian situation to worsen rapidly.

Thursday’s horrific attack by ISIS Khorasan at the airport illustrates what is at stake.

Pakistan’s government claims by working with the Taliban rather than isolating them they can maintain security in the country and prevent Afghanistan from descending into civil war as it did in the past.

Islamabad is on the front foot of a PR blitz trying to make its case at a time when many western capitals see it as one of the reasons the nation building project failed over the last 20 years.

Please use Chrome browser for a more accessible video player

Sky’s Adam Parsons reports from Ramstein Air Base in Germany, where thousands of Afghan refugees are waiting to be flown to the US to start new lives

The country stands accused of playing a “double game” – appearing as a staunch ally while at the same time sponsoring the militant group and providing sanctuary and support.

The reason for this duplicity, it’s claimed, is that Pakistan has an interest in seeing Islamist rulers – not a democratic government – in Kabul as a way of increasing strategic depth and influence in its perpetual fight against its powerful neighbour India to the east.

But the Pakistani government claims these accusations are “not based in reality” and it is being used as a “scapegoat” for the failures and miscalculations of others.

The argument it makes is that there was never a military solution to Afghanistan in the first place and such a victory was therefore illusory.

It also claims that after Afghanistan it is the biggest victim of the so called war on terror with as many as 80,000 dead and two million people internally displaced.

And the reality is that the West will most likely have to recognise the new bearded rulers in Kabul.

In microcosm we have already seen that play out with international forces humiliatingly having to coordinate with the group during the airlift.

And then there is the bigger question – engage with the Taliban, or not to stop groups like ISIS from becoming stronger in the region?

Both are extreme Sunni Islamist militants but there is great enmity between them.

Pakistan certainly believes that our enemy of 20 years may, in that fight, turn out to be our friend.