Pakistan's shadowy secret service
Pakistan's directorate for Inter-Services Intelligence, usually called the ISI, is accused of many vices.
Critics say it runs "a state within a state", subverts elected governments, supports the Taliban and is even involved in drug smuggling.
The Pakistani authorities deny the allegations.
Like many other military intelligence organisations, the shadowy ISI zealously guards its secrets and evidence against it is sketchy.
However, the agency is a central organ of Pakistan's military machine which has played a major - often dominant - role in the country's often turbulent politics.
The ISI was established in 1948 - as Pakistan engaged India in the first war over Kashmir - to be the top body co-ordinating the intelligence functions of its army, air force and navy.
In the 1950s, when Pakistan joined anti-communist alliances, its military services and the ISI received considerable Western support in training and equipment.
The ISI's attention was focused on India, considered Pakistan's arch-enemy.
But when Ayub Khan, the army commander-in-chief, mounted the first successful coup in 1958, the ISI's domestic political activities expanded.
As a new state bringing together diverse ethnic groups within what some described as contrived borders, Pakistan faced separatist challenges - among Pashtuns, Balochis, Sindhis and Bengalis.
Much of the country's early history was shaped by politicians seeking regional autonomy and the central civilian and military bureaucracies trying to consolidate national unity.
The ISI not only mounted surveillance on parties and politicians, it often infiltrated, co-opted, cajoled or coerced them into supporting the army's centralising agenda.
Defeat and disgrace
The army ran the country from 1958 to 1971, when East Pakistan broke away with Indian and Soviet help to become Bangladesh.
The ISI and the Pakistani military were thoroughly discredited and marginalised after the war.
But they gained fresh purpose in 1972 when Zulfiqar Ali Bhutto, the new civilian leader, launched a clandestine project to build nuclear weapons.
A year later military operations were launched against nationalist militants in Balochistan province.
These two events helped rehabilitate the ISI and the military.
After Bhutto was ousted by Gen Zia ul-Haq in 1977, the Balochistan operations were ended but the nuclear programme was expanded.
The Marxist revolution in Afghanistan in the same year threatened Pakistan by opening a second "strategic front" (the first being with India to the east).
The ISI was restored to its past eminence.
The Soviet invasion of Afghanistan in December 1979 transformed the regional setting.
President Carter and his national security adviser, Zbigniew Brzezinski, built a Western-Muslim coalition with Britain, France, West Germany, China, Egypt, Turkey, Saudi Arabia and the United Arab Emirates playing key roles.
Revolutionary Iran offered some aid to anti-Soviet guerrillas in western Afghanistan.
But all other foreign assistance to the mujahideen arrived via Pakistan, to be handled by the ISI whose Afghan bureau co-ordinated all operational activities with the seven guerrilla militias.
This was done in such secrecy that the Pakistani military itself was kept in the dark.
Just to get a sense of the scale of the operation - the CIA provided enough arms to equip a 240,000-man army, and the Saudis matched US funding dollar for dollar.
Other countries provided arms and money and Muslim countries also encouraged volunteers to join the jihad or holy war.
Foreign money helped to establish hundreds of madrassas (religious schools) in Pakistan's cities and frontier areas.
These turned out thousands of Taliban (students) who joined the mujahideen in the anti-Soviet campaign.
The ISI managed this operation, handling tens of thousands of tons of ordnance every year and co-ordinating the action of several hundred thousand fighters in great secrecy.
Eventually, in 1988, the Soviet Union agreed to withdraw its forces by 1989, and did so.
This was seen as a great victory for the mujahideen and their patrons in Pakistan and farther afield, and a trigger for the subsequent Soviet collapse.
The 10-year-long Afghan war not only bestowed on the ISI huge experience of covert warfare, it also created for it a vast reserve of motivated manpower that could be used as its proxy in the geo-strategic horseplay of regional powers.
The strength of this proxy force has been sustained through endless fresh recruitment from religious seminaries and from areas under the militants' control.
There is plenty of evidence that in 1988, without directly involving Pakistan in a conflict, the ISI moved Islamic militants from Afghanistan to Indian-administered Kashmir to start an insurgency there.
The insurgency still continues and its funding, logistics and communications are all believed to be controlled by the ISI.
India has repeatedly accused Pakistan, and especially the ISI, of involvement in Kashmir and in attacks elsewhere in India.
In Afghanistan, many believe the ISI helped the Taliban at a tactical as well as a strategic level to capture power and defeat forces sympathetic to India, Iran or the Central Asian states.
After the attacks of 9/11, the Pakistani government joined the US-led coalition against al-Qaeda and the Taliban, but many say the ISI continues to support the Taliban and even helped them to carve out sanctuaries in Pakistani territory.
Former Pakistani President Pervez Musharraf's attempt to clip the ISI's wings and hand over its operations to the Military Intelligence (MI) translated into huge political costs for him.
It is widely suspected that the Red Mosque militants who challenged the Musharraf regime in Islamabad had the ISI's backing.
The siege of the Red Mosque in July 2007 led to the killing of more than 100 people holed up in the mosque, including male and female students of a religious seminary.
The event sparked the formation of the Tehrik Taliban Pakistan (TTP), which has launched scores of attacks against Pakistani military and civilian targets.
The lawyers' movement during 2007-8, which ultimately brought Mr Musharraf down, is also believed to have enjoyed direct or indirect support from the ISI.
More recently, the "Punjabi Taliban" that is attacking government targets under the TTP banner are known to have been facilitated by the ISI in their sanctuaries in the north-western Waziristan tribal region.
The BBC has been told from reliable sources that both the Punjabi Taliban and tribal fighters are conducting operations against Nato forces in Afghanistan with the logistical support of the Pakistani military.
Sources say this support is orchestrated by the ISI.