Image copyright Reuters Image caption A recent army operation in North Waziristan flushed out many militants in the area

In recent months the fortunes and allegiances of Pakistan's militants have proved mercurial. Formerly united fronts fractured while the army drove others out of their strongholds. Then al-Qaeda said it would take the initiative in South Asia proving, as the BBC's M Ilyas Khan reports, that the insurgents are still a potent force.

The claim by al-Qaeda that it carried out the 13 September attack on the Pakistan Navy's dockyard in Karachi city yet again shows the militants' ability to strike deep in Pakistan despite recent setbacks.

In a statement placed on one of its web portals, al-Qaeda claimed the operatives of its recently launched wing - al-Qaeda in the Indian Sub-continent (AQIS) - seized control of a Pakistani frigate in order to attack some nearby American vessels.

Image copyright Reuters Image caption Karachi's naval dockyard has long been a prime militant target

Few will believe that - not only because Pakistani forces have been able to contain similar attacks in the past, but also because the present one comes when a major offensive by the military has disrupted the militants' command centres in Miranshah, North Waziristan.

The Pakistani navy said it repelled the attack, killing two militants and capturing four others. It said it thwarted what looked like the militants' attempt to carry out an attack along the lines of the bombing of the USS Cole in Yemen in 2000.

'Soft' militant policy

Both al-Qaeda and the Pakistani government said the attack was carried out with inside help. This admission comes as a stark reminder of the lingering concerns about the ability of jihadi militants to penetrate Pakistan's security installations.

But could a group whose formation was only announced on 4 September mount such an audacious attack just days later?

It would seem unlikely, unless one considers the Pakistani military's alleged "soft" policy towards militants in the past, and al-Qaeda's local links that go back more than two decades.

Image copyright AP Image caption Militants based themselves in Pakistan's tribal areas, where many foreign fighters also settled

The military exposed its lower and middle ranks to a wave of radicalisation that came with the Afghan war of the 1980s. Its adoption of jihad as one of its three mottoes (the others being faith in God, and fear of God) created sympathy in its ranks for militancy and the Afghan jihad, and led to its subsequent anti-Americanism in the post-9/11 period.

During the Afghan war, and later the 1989-2003 "jihad" in Indian-administered Kashmir, Pakistan's ISI intelligence service was widely accused of having worked closely with militant groups, training and arming them and underwriting their operations.

Due to the Saudi origins of its leadership, al-Qaeda emerged as the "holiest", and also the wealthiest of militant groups in the South Asian region.

Same old leaders

The organisation was formed in the city of Peshawar in late 1980s, and a number of top Pakistani militant leaders played a role in shaping its training, planning, operational and propaganda arms.

Image copyright AFP Image caption The death of Hakimullah Mehsud exposed divisions in the militant network

The recently appointed chief of al-Qaeda in South Asia, Asim Umar, is a Pakistani militant who has spent years with al-Qaeda leaders in North Waziristan where he moved in the early 2000s and set up his own group.

Prior to that, he worked with such Kashmir-focused groups as Harkatul Mujahideen and Jaish-e-Mohammad. So neither the AQIS nor its leaders are new to the region or the task at hand.

Over the years, militants trained in North Waziristan have proved their ability to strike pretty much any target in Pakistan, irrespective of which group claims the responsibility.

The same is the case now.

Image copyright Reuters Image caption After the Pakistan military offensive, attacks in Pakistan virtually ceased

Since the Pakistani military offensive, which started in mid-June, militant attacks virtually ceased in Pakistan, suggesting significant disruption to militant networks.

Internal divisions in the militants also came to the fore as the main umbrella group of Pakistani Taliban, the TTP, split into at least three regional factions.

But in the past couple of weeks, there have been signs the insurgents might be coming back to life.

Last month, militants said to be affiliated with a Mehsud faction of TTP and the Islamic Movement of Uzbekistan (IMU) launched a synchronized attack on two air bases in the south-western city of Quetta.

More than 10 of them died in the fighting that broke out.

Foreign fighters

There have also been a couple of suicide attacks on police in the northwest, and a raid on a Pakistani border post from Afghan territory - claimed by another break-away faction of the TTP which calls itself Jamiat-e-Ahrar.

Not to be left behind, the central TTP franchise led by Mullah Fazlullah claimed the naval dockyard attack. In hindsight, one would imagine they are happy to share the accolades with AQIS as they never contradicted the latter's claim.

As the army's offensive in North Waziristan rumbles on, there certainly seems to be a race among the various militant factions to show that they are still alive and kicking.

Image copyright Getty Images

For al-Qaeda, it may well be a signal to the Iraq-based Islamic State (IS) that it's still in charge in the South Asian region.

While it may struggle to mount attacks in India, it has plenty of followers in countries like Afghanistan, Pakistan, Bangladesh, Myanmar and Maldives, some of whose citizens have been training in North Waziristan.

In addition, there has been a strong presence of militants from Central Asia, north-west China, Middle East, the Caucasus region and the Far East.

Traditionally, most of the foreign groups have tended to gravitate towards al-Qaeda and its TTP allies.

Sources say the AQIS is now planning to consolidate these groups into a new force, separate from the Afghan Taliban who, according to sources, are seen by the al-Qaeda leadership as "indigenous" both in terms of ethnicity and ideological aims.