Image copyright EPA Image caption The Peshawar school attack was widely condemned

Ever since the Pakistan Taliban massacred 132 schoolboys in a Peshawar school last December, the Pakistan army has been confronting some of the country's militants, with unprecedented determination.

But the campaign is still patchy. While the Pakistan Taliban have been forced on to the back foot, other Pakistan-based militant outfits have been left undisturbed.

Publicly, Pakistani officials insist that they no longer make a distinction between the "good" Taliban (proxy forces of the Pakistan state) and the "bad" Taliban (which mount sectarian or anti-state attacks).

But privately they argue the army has to prioritise which groups to confront first. The immediate, urgent task, they say, is to fight the militants who have caused tens of thousands of deaths within Pakistan itself.

Afghan attacks

It means militant groups such as the Haqqani network, which focuses most of its efforts on Afghanistan, can fight on unimpeded. The group, which is based in Pakistan's tribal areas, is believed to have mounted a series of attacks on Kabul this summer.

It has been a devastating campaign. In the first six months of 2015, the UN Assistance Mission in Afghanistan documented the highest level of civilian casualties in the country since it began keeping authoritative records in 2008.

Similarly, the Afghan Taliban have stepped up their military activity - most recently in the city of Kunduz in the north of Afghanistan.

Image copyright Reuters Image caption Taliban fighters have been out on the streets of Kunduz, many posing for photos

Kabul for years has complained that many Afghan Taliban leaders live in and around the Pakistani city of Quetta.

When asked about the issue, Pakistani military officials say that, with as many as three million Afghans in Pakistan, it is difficult to be sure who is living where.

The lack of an outright denial is deliberate. The perception that Pakistan controls the Afghan Taliban gives Pakistani officials diplomatic leverage. If the West wants peace in Afghanistan, they are implicitly suggesting, it will have to secure Pakistani co-operation to deliver it.

In fact, history suggests that the Afghan Taliban, while happy to accept Pakistani support, are quite capable of ignoring Islamabad's instructions and formulating their own policies.

Who are the Taliban?

Media playback is unsupported on your device Media caption The BBC's John Simpson has this assessment of the different Taliban groups

Co-operation

When the new Afghan President, Ashraf Ghani, won power in 2014, he said improving the relationship with Pakistan was a top priority: if Islamabad would cut its links with the Afghan Taliban, then Kabul would try to prevent anti-Pakistan forces finding sanctuary in Afghanistan.

The two countries, he suggested, could only find stability by working together.

But for all the hope that President Ghani engendered, Islamabad and Kabul have reverted to hurling accusations at each other. And the distrust seems set to continue.

Image copyright AP Image caption Afghanistan President Ashraf Ghani has spoken of improving his country's relationship with Pakistan

Geostrategic concerns

Senior Pakistani military officers say one of the reasons they have a continued interest in Afghanistan is because India is extending its influence there.

Islamabad fears that, among other things, Delhi is using its presence in Afghanistan to build a closer relationship with Baloch separatists, who for a decade have been fighting to split away from Pakistan.

The issue is especially sensitive because of Pakistan's plans to construct the China Pakistan economic corridor. The planned trade route will run through Balochistan, close to the Afghan border, down to the new deep-sea port of Gwadar.

Pakistan is hoping the corridor could generate billions of dollars of revenue.

It is a highly complex geostrategic situation.

Put at its most succinct, Pakistani strategists are supporting Islamist militants to counter Indian intelligence officers working with Baloch nationalists to thwart Chinese traders.

It all shows the extent to which the Great Game, in which outside powers struggle for control of Afghanistan, is alive and well.

The Great Game

Strategic rivalry between the British and Russian Empires for control of central Asia during the 19th and early 20th Centuries

Officially ended with the Anglo-Russian Convention of 1907, which divided Persia into three zones, declared Afghanistan an official protectorate of Britain and said that neither Russia nor Britain would interfere in Tibet's internal affairs

Britain's Capt Arthur Conolly is generally considered to have coined the term

Rudyard Kipling's 1901 novel Kim is set against the backdrop of the Great Game, which brought the phrase into the mainstream

As has so often been the case in the past, the stability of Afghanistan depends on it being left alone. But the regional powers all see the country as a place that can cause them problems.

The result is that many of Afghanistan's neighbours sponsor local, tribal and religious militias so as to prevent anyone else's proxy getting control.

It is a process Afghan civilians recognise all too well because, more often than not, they are the ones caught in the crossfire.