image sourceGetty Imagesimage captionTaliban and Pakistani soldiers guard Afghanistan's border with Pakistan

For some Western powers hoping to influence the new Taliban government, there are hopes that Pakistan could play a role as a mediator.

The country has a unique relationship with Afghanistan. They share a 2,570km (1,600 mile) border. They are significant trading partners. There are numerous cultural, ethnic and religious connections. The former Afghan leader Hamid Karzai once described the two countries as "inseparable brothers".

But for some capitals queuing up to revive their relationship with Islamabad, there are mixed feelings.

Pakistan has not been seen by all as a firm ally in the battle against jihadist terrorism. It has long been accused by many in the United States and elsewhere of providing support for the Taliban, something it denies.

Yet diplomats in the West want to persuade the Taliban to allow their nationals to leave Afghanistan, to let humanitarian aid in and to govern moderately. And that means they need to talk to countries like Pakistan and others in the region.

What is Pakistan's relationship with Afghanistan and the Taliban?

Critics of Pakistan have accused it of hedging its bets over Afghanistan and the Taliban.

After the 9/11 attacks that were planned in Afghanistan, Pakistan positioned itself as an ally of the US in the so-called "war on terror".

But at the same time, parts of the country's military and intelligence establishment maintained links with Islamist groups in Afghanistan like the Taliban. Those links, so it is claimed, at times turned into significant material and logistical support.

media captionTaliban parade military equipment through the streets of Kandahar

The belief among strategists was that Pakistan wanted a stake in Afghanistan, to ensure it did not end up with a government that was pro-India. The extent and duration of Pakistan's support for the Taliban is disputed.

But when the Taliban were last in power 20 years ago, Pakistan was one of the few countries to formally recognise its government. And when the Taliban seized Kabul last month, Pakistani Prime Minister Imran Khan declared the group were "breaking the chains of slavery".

What is Pakistan worried about?

Pakistan's historic support for the Taliban does not, however, mean it is entirely relaxed about the group's takeover in Kabul. Pakistanis have suffered hugely over the years at the hands of Islamist terror groups launching attacks over the border from Afghanistan.

Pakistan has a huge interest in ensuring the new government in Kabul cracks down on groups like Al Qaeda and the local Islamic State offshoot – ISIS-K. That means Pakistan has an interest in the Taliban acting firmly and not allowing Afghanistan to descend into an ungoverned space.

  • ANALYSIS: What does the future hold for Afghanistan?
  • EXPLAINER: Who are the Taliban?
  • VISUAL EXPLAINER: How many Afghan refugees are fleeing?

The other great concern of Pakistan is a refugee crisis. The country already has about three million Afghan refugees from previous wars and, with its ravaged economy, it cannot afford to support any more.

Pakistan's High Commissioner to the UK, Moazzam Ahmad Khan, told the BBC Today programme: "We don't really have the capacity to take more refugees in and that's why we're suggesting – and requesting – that let's sit down together and work on the possibility of avoiding that eventuality."

What does this mean for relations with West?

Pakistan's relations with the West are not great.

Perhaps the poorest are with the United States. Joe Biden has refused even to call Prime Minister Khan since he became president.

Lt Gen HR McMaster, the former US National Security Adviser, told a Policy Exchange seminar this week that Pakistan should be treated as a "pariah state" if it did not stop its support for jihadi groups.

"We have to stop pretending that Pakistan is a partner," he said. "Pakistan has been acting as an enemy nation against us by organising, training and equipping these forces and by continuing to use jihadist terrorist organisations as an arm of their foreign policy."

image sourceGetty Imagesimage captionAfghans have been waiting at the border with Pakistan

But that American view has not stopped other Western powers knocking on Pakistan's door. In recent days, foreign ministers from Britain and Germany have visited Islamabad. Italy's will go soon.

Diplomats believe – or at least hope – that Pakistan still holds some sway over the Taliban. They also fear that shunning Pakistan risks encouraging the country even further into the warm embrace of China.

The question of course is whether Pakistan really can influence the Taliban.

Mullah Abdul Ghani Baradar, widely tipped to be the leader of the new government, has in the past spent time in Pakistani detention. How warm he remains towards his former gaolers remains to be seen.