This week marks the 10th anniversary of the war in Afghanistan. U.S. troops are starting to leave. And NATO is supposed to turn over security responsibility to Afghans by the end of 2014 -- although the Afghan army is far from ready to counter Taliban violence.

Yet the most potent threat to Afghanistan -- and to U.S. plans to withdraw troops -- doesn't come from the Taliban. It comes from our supposed ally, the Pakistani military.

This dirty secret burst into the open last month, when the departing chairman of the Joint Chiefs, Adm. Mike Mullen, called Pakistan's bluff in testimony before Congress.

Mullen had tried for years, with occasional success, to privately persuade his Pakistani counterparts to shift gears. But his patience wore thin after Osama bin Laden was found in a Pakistani garrison town and the Pakistani military denied all knowledge of his presence. Mullen lost all patience after the Taliban's Haqqani network targeted U.S. diplomats and soldiers in several attacks.

Mullen's harsh words reflected recognition within the administration that Pakistan's dissembling can no longer be tolerated. But officials are still debating whether the Pakistani military can be pressured to change direction.

One man with good ideas on the subject is Peter Tomsen, a career diplomat who served as special U.S. envoy to the Afghan resistance from 1989 to 1992. Tomsen has just written a fascinating tome, The Wars of Afghanistan, that describes how the ISI funneled U.S. and Saudi money to the most radical Afghan Islamist groups during the 1980s struggle against the Soviets, and how it backed the ascension of the Taliban to power in 1996. Tomsen also details how the ISI consistently undermined the rise of more moderate Afghan leaders.

Tomsen said the ISI is trying to use the Taliban "to create a friendly government in Kabul that is dependent on Pakistan" and will be hostile to its archenemy, India, once the Americans have gone home.

This strategy is delusional and could backfire on Pakistan. Key Afghan Taliban groups such as the Haqqani network have links to Pakistani extremists who are fighting the Pakistani army.

So what's to be done? Here are Tomsen's suggestions:

Put the Haqqani network on the terrorist list for its bloody attacks on Afghan civilians.

Threaten to put Pakistan on the U.S. list of state sponsors of terror, which would mean U.S. and possibly European sanctions.

Make military aid contingent on real Pakistani cooperation against terrorists.

Give up illusions about talks with the Taliban. Pakistan has made clear that it will undermine such talks, unless they put its proxies in power; the ISI may have been behind the recent murder of Afghanistan's chief negotiator with the Taliban.

Rally Afghanistan's neighbors and other global powers concerned about Afghan chaos to pressure Islamabad. That includes India, Iran, Saudi Arabia, and China -- which may sell Pakistan weapons but will not be the sugar daddy Pakistan hopes for.

Don't send ground forces into Pakistan. It's too risky and could be counterproductive.

But the administration's message should be clear. Pakistan must choose: Halt terrorism by groups under its sway or face diplomatic isolation, with stark economic consequences. If Pakistan's military and the ISI continue to back extremists who kill Americans, they become America's enemy -- with all the consequences that entails.