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 Taleban and is even involved in drug smuggling.
Pakistan's government denies 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.
The ISI co-ordinated the action of several hundred thousand [anti-Soviet] fighters in great secrecy
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.
Gen Zia ul-Haq helped the US against the Soviets in Afghanistan
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 General 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.
Gen Musharraf denies the ISI is backing the Taleban
These turned out thousands of Taleban (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.
This is why Pakistan's President Pervez Musharraf feels it necessary to defend the ISI.
He has pointed out that the West backed the mujahideen, which went on to engender groups like al-Qaeda and the Taleban in the post-Soviet violence which consumed Afghanistan and brought about the US-led "war on terror".
Following the attacks of 11 September, 2001, Gen Musharraf has sought to rid the military, including the ISI, of Islamists within its ranks - a hangover from the Zia era.
Elements in the military have been accused of complicity in failed attempts on his life.
Pakistani government and ISI support for militant groups who left Afghanistan to fight Indian rule in Kashmir has been the cause of much friction with India.
India has repeatedly accused Pakistan, and especially the ISI, of involvement in Kashmir and in attacks elsewhere in India.