Pakistan's President Pervez Musharraf, the longtime military dictator who resigned Monday, was an ambivalent ally in the fight against radical Islamists.
Although the Pakistani leader did arrest some key al-Qaeda operatives, he let militants take over whole areas of his country along the Afghan border - where al-Qaeda's leadership is believed to be hiding. Little of the billions in U.S. aid since 2001 has gone to countering the terrorist threat.
So the biggest question for Americans, now that Musharraf is toast, is whether an elected Pakistani government will be able to confront the jihadis. So far the signs are doubtful.
An equally big question is whether Pakistan's army, historically more eager to confront India than to fight Islamists, will recognize that jihadis have become an existential threat to their nuclear-armed state.
For years, Pakistani democrats claimed that only an elected leadership could rally popular support for a fight against terrorists. Pakistan's people regard the terrorist threat as a problem foisted on them by the United States, which failed to stabilize Afghanistan. In a 2007 poll, 89 percent of Pakistanis rejected any cooperation with the United States in the "war on terrorism."
The late Benazir Bhutto was the only politician to argue publicly that this war was Pakistan's, too. She said Pakistani intelligence should stop training jihadis to fight India in Kashmir. No wonder she was assassinated by militants late last year.
The leaders of Bhutto's Pakistan Peoples Party echo her strong stand against extremists in private, but not in public. They are hamstrung by a coalition government in which the other party's leader, Nawaz Sharif, opposes fighting the extremists.
Since the new government took office, the terrorists have expanded their reach. Deals with extremist groups haven't helped. There is enormous mistrust between the army and the government. Nor do civilian leaders control the main Pakistani intelligence agency, which the CIA believes is helping the militants.
So where does hope lie? How can the next U.S. president help Pakistan confront its growing terrorist threat?
One glimmer may rest with Pakistan's army, according to Shuja Nawaz, an expert on the Pakistani military and author of Pakistan, Its Army, and the Wars Within, who just returned from Pakistan. According to Nawaz, Pakistan's army now recognizes that the internal insurgency that threatens the state "is Pakistan's war" - not just America's fight.
Nawaz also says "the [Pakistani] army absolutely understands its priority is not India but is internal." The army is finally training units formerly geared to fight a conventional war against India for action against insurgents. Some units are being moved from the Indian border to areas that insurgents have mauled.
But the army knows it is unpopular in these areas. It desperately wants to avoid civilian casualties, while protecting tribal leaders who oppose the militants. The army commander, Gen. Ashfaq Kayani, recognizes the need to funnel economic aid to troubled areas, creating jobs and bolstering the hand of tribal elders.
If this sounds like what Gen. David Petraeus did in Iraq's Anbar Province, that's no coincidence. "Some of the thinking in the army . . . is in accordance with what Petraeus has done [in Iraq]," says Nawaz. "They see the need for quick impact projects [such as those funded by U.S. army commanders in troubled Iraqi districts]."
Petraeus soon will take over as head of CENTCOM, the army command that includes Pakistan (as well as the Middle East). Can he pull off another miracle, helping Kayani to train Pakistani units to fight jihadis? Can he help convince the Pakistani army to shift gears and use American economic and military aid for the purposes intended?
And can he convince the army that the internal war against jihadis can't be delinked from fighting the Taliban's war against Afghanistan? If Pakistan's army and intelligence agencies won't stop supporting jihadis as a hedge against India, they won't be able to resolve the internal jihadi threat.
Finally, can an American general convince Pakistani counterparts they need to coordinate with civilian leaders? There is intense public resistance in Pakistan to overt U.S. military intervention. It will be hard to rally public support for a Pakistani war on jihadis unless the civilian government backs it.
Pakistan's jihadi challenge is even tougher than Iraq's, but Petraeus may be critical to the solution. He may be the best hope in a picture that is otherwise bleak.