The ability of militants to breach security and kill with ferocity has confounded the country. Extremists have been carrying out numerous attacks for years, killing military personnel, police, school children and worshippers kneeling in prayer.
One reason is the sheer number and variety of extremist groups, some of which have been battling the military in a bid to bring down the government. Another intertwined reason is the state's complicated relationship with extremists. The powerful military has a history of using some militants to target neighbor and rival India, and successive governments have sought to win political support from hard-liners by promoting and cultivating extremist ideologies. Then there is also Pakistan's connection with generations of militants involved in the more than 30 years of constant warfare in neighboring Afghanistan.
WHERE IT ALL BEGAN When the Soviet Union Russians invaded Afghanistan in 1979, Pakistan became the staging arena for the mujahedeen, or Islamic holy warriors, who fought the Russian occupation in one of the last great Cold War battles.
These holy warriors were backed by the United States, and some even travelled to Washington to meet the then U.S. President Ronald Reagan. Among those who sat with Reagan were militants who later were declared terrorists by the United States, such as Jalaluddin Haqqani, head of the Haqqani network, now one of the most ferocious militant groups in Afghanistan and Pakistan.
Washington's ally in the Afghan fight was Pakistan's then-military dictator, Gen. Mohammed Zia-ul Haq. Currying the support of hard-liners, Zia turned his relatively liberal country into one ruled according to strict interpretations of Islamic law. Public flogging and other measures were introduced.
Militants and hard-line religious parties were given government support, including hundreds of millions of dollars used to promote their religious agendas. Zia invited Islamic militants to fight in Afghanistan, including Osama Bin Laden. The Russians withdrew in 1989 and the proxy government it set up collapsed soon after, with Zia then able to tout holy war as a way to defeat a superpower.
MILITANT GROUPS Now a multitude of militant groups are flourishing, championing a variety of causes. Some have declared war on the Pakistan government and military. Examples are the Pakistani Taliban, or Tehrik-e-Taliban, and breakaway factions like Jamaat-ul-Ahrar. They want to overthrow the government and impose their version of Islamic law across the country. Under pressure from military offensives, the Tehrik has been fragmenting, with dozens of smaller groups breaking away and also carrying out attacks, though on a smaller scale.
Other groups, like Lashkar-e-Tayyaba and Jaish-e-Mohammed, focus on fighting Pakistan's neighbor and rival India. They have no quarrel with the Pakistani army — and often trace their origins to military support — and are based in Punjab, Pakistan's most populous province.
Jaish-e-Mohammed was blamed for an attack last month on an Indian base that killed 17 troops in Indian-ruled Kashmir. The Himalayan state of Kashmir is divided between India and Pakistan, is claimed by both and was at the center of two of the three wars between the countries. Pakistan's military denies aiding militants fighting in Kashmir. But it is widely believed that as long as the Kashmir dispute remains unresolved, anti-Indian militants will remain active and even be assisted by Pakistan.
The toxic mix of militants does not end there. A variety of Sunni extremist groups have carried out bloody attacks on Shiite civilians. The Islamic State group has also claimed a presence in Pakistan, although its strength is still undetermined.
STATE RESPONSE Despite repeated denials, Pakistan's army is still often accused of being selective in which groups it cracks down on. Pakistan's government has devised a National Action Plan aimed at curbing militancy but many complain its implementation has been erratic.
The army has carried out successive campaigns in the tribal regions, destroying weapons, explosive caches and killing militant leaders. Thousands of soldiers have been killed in the fighting. Their targets have been those groups who have openly declared war on Pakistan's military and state.
By comparison, the Afghan Taliban and the Haqqani network are believed to operate relatively freely in Pakistan's border regions to carry out operations in neighboring Afghanistan. The Haqqani group has links to Pakistan's military and intelligence dating back to the 1980s, and it has repeatedly said it has no fight with Pakistan.
Also, the leadership of groups attacking India move freely in Pakistan, including a founder of Lashkar-e-Tayyaba group, Hafiz Saeed, who has a $10 million U.S.-imposed bounty and is one of India's most wanted men.
The issue has been one of the points of contention in Pakistan's complicated relationship with the United States. Washington gives Pakistan billions in aid and considers it an ally in the war on terror, but often complains Islamabad is not doing enough to get rid of Afghan militants, particularly the Haqqanis.
SECTARIAN SHADES After Iran's Islamic revolution in 1979, competition for influence revved up between majority Shiite Iran and mainly Sunni Saudi Arabia — and that was reflected in Pakistan. Saudi Arabia funded hard-line Sunnis in Pakistan and built religious schools propagating the kingdom's strict Wahhabi sect of Islam.
These schools often encourage discord with Shiite Muslims. Many of Afghanistan's Taliban studied at these schools while they lived in Pakistan as refugees. Saudi Arabia has also been accused of supporting Lashkar-e-Jhangvim which has attacked Shiites.
Iran, meanwhile, has sent money to Shiite Muslim groups, including the Tehrek Nifaz Fiqah-e-Jafaria, which calls for the implementation of Islamic Shariah law.