Pakistani security forces fire toward an attacker next to a security checkpoint in Quetta on May 17, 2011. (BANARAS KHAN/AFP/GETTY IMAGES)

Embarrassed by the Osama bin Laden raid and by a series of insurgent attacks on high-security sites, top Pakistani military officials are increasingly concerned that their ranks are penetrated by Islamists who are aiding militants in a campaign against the state.

Those worries have grown especially acute since the killing of bin Laden less than a mile from a prestigious military academy. This week’s naval base infiltration by heavily armed insurgents in Karachi — an attack widely believed to have required inside help — has only deepened fears, military officials said.

Pakistan’s army chief, Gen. Ashfaq Kayani, who like the civilian government has publicly expressed anger over the secret U.S. raid, was so shaken by the discovery of bin Laden that he told U.S. officials in a recent meeting that his first priority was “bringing our house in order,” according to a senior Pakistani intelligence official, citing personal conversations with Kayani.

“We are under attack, and the attackers are getting highly confidential information about their targets,” said the official, who, like others, would speak only on the condition of anonymity to discuss a sensitive matter.

Pakistan’s top military brass claimed to have purged the ranks of Islamists shortly after the Sept. 11, 2001, attacks. Since then, the nation’s top officials have made repeated public assurances that the armed forces are committed to the fight against extremists and that Pakistan’s extensive nuclear arsenal is in safe hands.

But U.S. officials have remained unconvinced, and they have repeatedly pressed for a more rigorous campaign by Pakistan to remove elements of the military and intelligence services that are believed to cooperate with militant groups.

U.S. Secretary of State Hillary Rodham Clinton, on a previously unannounced visit to Islamabad on Friday, emphasized U.S. demands for greater cooperation in the war against al-Qaeda, the Taliban and other violent Islamist organizations that have taken root in Pakistan. Standing beside Adm. Mike Mullen, chairman of the Joint Chiefs of Staff, Clinton said the United States would be looking “to the government of Pakistan to take decisive steps in the days ahead.”

It is unclear how authentically committed Kayani and other top military leaders are to cleansing their ranks. U.S. officials and Pakistani analysts say support by the nation’s top military spy agency for insurgent groups, particularly those that attack in India and Afghanistan, is de facto security policy in Pakistan, not a matter of a few rogue elements.

But Kayani is under profound pressure, both from a domestic population fed up with the constant insurgent attacks and from critics in the U.S. government, who view the bin Laden hideout as the strongest evidence yet that Pakistan is playing a double game.

U.S. officials say they have no evidence that top Pakistani military or civilian leaders knew about bin Laden’s redoubt, though they are still examining intelligence gathered during the raid. Some say they doubt Kayani or Lt. Gen. Ahmed Shuja Pasha, head of the military’s Inter-Services Intelligence agency, had direct knowledge; others find it hard to believe they did not, particularly because Kayani was head of the ISI in 2005, when bin Laden is believed to have taken refuge in Abbottabad.

“I think he was in protective custody,” one former U.S. official who worked closely on Pakistan issues said of bin Laden.

Pakistan strenuously denies that. But military officials acknowledge that members of the services have cooperated with militants. One senior military official said military courts have in recent years convicted several soldiers for roles in attacks on security installations — convictions that have not been made public. Four naval officers previously arrested on suspicion of links to militants were questioned this week in connection with the assault on the naval base in Karachi, another security official said.

The senior military official said belief in militant jihad — long glorified in the national education curriculum — is prevalent in the rank and file, making screening for it a daunting task that the military has been loath to perform.

Shadowy arm of the ISI

The ISI is believed to have an entire branch — known as the “S Wing” — devoted to relationships with militant organizations. Some analysts believe the wing operates with relative independence, whether by design or default, that gives top brass plausible deniability when cooperation between the spy service and insurgents comes to light.

U.S. officials, for example, say they do not believe Pasha or Kayani knew about Pakistani militants’ plans to attack Mumbai in 2008. But federal prosecutors have implicated the ISI in a trial underway in Chicago, where the star witness has said he was paid by the spy agency to help arrange the siege.

U.S. officials have emphasized since the bin Laden raid that billions of dollars in U.S. assistance could end if Pakistan is found to have harbored the al-Qaeda leader. Pakistani officials said that pressure has included demands that the military purge Islamists in its ranks and identify agents connected to bin Laden.

“We take the Pakistanis at their word that they’re committed to an aggressive fight against militants and to the investigations they’ve announced. But it’s way too early to say that their actions are honoring their stated commitments,” one U.S. official said.

Disdain for the U.S.

Working against any reform effort is the fervent anti-Americanism felt throughout Pakistan, including within the armed forces. Some Pakistani officials and soldiers accuse the United States of using the bin Laden raid to embarrass the nation into doing American bidding. This week, talk-show pundits condemned the navy’s security lapse at the Karachi base but also brimmed with conspiracy theories about CIA orchestration of the siege.

“Any public action on the part of the military at this point will be seen as capitulating to U.S. demands,” said Shuja Nawaz, director of the South Asia Center at the Washington-based Atlantic Council.

One Pakistani security official said the Karachi attack had prompted the military to begin a “thorough overhauling” of the armed forces. But, he asked: “if someone is helping the militants from inside the forces, why are they doing it? And the answer, to us, is their disdain for the U.S. and anger at Pakistanis cooperating with Americans.”

Special correspondents Haq Nawaz Khan in Peshawar and Shaiq Hussain in Islamabad and staff writer Greg Miller in Washington contributed to this report.