Pakistan's shadowy secret service, the ISI
Pakistan's directorate for Inter-Services Intelligence, or ISI, is once again facing accusations of double-standards over its role in the fight against al-Qaeda and the Taliban.
Many observers find it hard to believe the organisation had no idea that Osama Bin Laden had been living under the nose of the Pakistani military until his death.
As to the US special forces raid that killed the al-Qaeda leader, questions abound about what the ISI knew and when it knew it.
Similar Western doubts over the ISI's loyalties have been a recurring theme in recent years.
In documents leaked in April 2011 on the Wikileaks website, US authorities described the ISI as a "terrorist" organisation on a par with al-Qaeda and the Taliban.
In the same month the US military's top officer, Adm Mike Mullen, also accused the ISI of having links with the Taliban.
He said it had a "long-standing relationship" with a militant group run by Afghan insurgent Jalaluddin Haqqani, which targets US troops in Afghanistan.
The list does not end there.
In June 2010 the ISI was accused of giving funding, training and sanctuary to the Afghan Taliban on a scale much larger than previously thought.
The paper published by the London School of Economics said that Taliban field commanders suggested that ISI intelligence agents even attend Taliban supreme council meetings - and that support for the militants was "official ISI policy".
Much of the high level of concern among some Western countries over the role of the ISI was expressed by British PM David Cameron in 2010.
He accused the country of "looking both ways" when it came to fighting terrorism and suggested that elements in Pakistan were guilty of promoting the "export of terror".
The Pakistani government has consistently rejected all the allegations against the ISI as "negative propaganda" by the US and its allies.
It has also dismissed suggestions that the ISI is run as "a state within a state", subverts elected governments and is involved in drug smuggling.
The truth will no doubt always be murky - because like many other military intelligence organisations, the shadowy ISI zealously guards its secrets and evidence against it is sketchy.
What is not in doubt however is that the agency is a central organ of Pakistan's military machine and has played a major - often dominant - role in the country's volatile 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.
In the dark
The Soviet invasion of Afghanistan in December 1979 transformed the regional setting.
All foreign assistance to mujahideen rebels at that time arrived via Pakistan, to be handled by the ISI whose Afghan bureau co-ordinated operational activities with the seven guerrilla militias.
This was done in such secrecy that the Pakistani military itself was kept in the dark.
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.
In 1989, the Soviet Union withdrew its forces.
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.
Despite denials from Islamabad, correspondents say 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.
India has repeatedly accused Pakistan, and especially the ISI, of involvement in Kashmir and in attacks elsewhere in India - including the 2008 Mumbai (Bombay) attacks in which gunmen killed 165 people.