What does Pakistan really want in Afghanistan? That question has become all the more urgent since Admiral Mike Mullen, Chairman of the Joint Chiefs of Staff, accused Pakistan of being indirectly responsible for last week's attack on our embassy in Kabul. Reports of a second possible attack, on Sunday, on the building alleged to house the local CIA station will, no doubt, fuel further speculation. Assessing Pakistan's interests in Afghanistan through the prism of honesty and realpolitik rather than wishful thinking may be the only way we're going to get out of this messy war.

For a start, we need to understand that Pakistan intends to bring down the government of Afghan President Hamid Karzai, even if that means taking on its sometime U.S. ally. Pakistan hates Karzai out of a conviction that he has made common cause with Pakistan's strategic nemesis, India, and a suspicion that the Afghan leader intends to harm Pakistan's strategic interests in other ways. And, of course, the hatred is mutual. Rightly or wrongly, Karzai believes that Pakistan's Inter-Services Intelligence Directorate (ISI) assassinated his father, and would do the same to him given half a chance.
(Read what Pakistan really envisions as an endgame for Afghanistan.)

A second misunderstanding we need to dispense with is that the ISI is somehow a rogue organization outside of Pakistan's chain of command and is pursuing a pro-Taliban agenda all its own. The Pakistani army can remove the ISI director, General Ahmad Shuja Pasha  or any other officer of the organization  at a moment's notice. So, if the ISI did indeed sponsor an attack on the U.S. embassy in Kabul, such a step should be assumed to have been taken with the consent of the power that be in Pakistan, i.e. the military establishment. The idea that to make our Pakistan problem go away, the ISI needs to be "cleaned up" is naive. The Pakistani actions that make life difficult for the U.S. in Afghanistan are driven by a clear-sighted strategic agenda.

As for the Pakistani proxy accused of carrying out the embassy attack, the Haqqani network, we need to understand why Pakistan won't give it up or act against it as the U.S. demands. With up to 15,000 fighters and effective control of large parts of eastern Afghanistan and Pakistan's North Waziristan, the Haqqanis are an indispensible party to a peace settlement in Afghanistan  and a vehicle for securing Pakistan's interests in that country after the U.S. withdraws. To sever relations with the Haqqanis now would mean Pakistan giving up a large degree of influence in Afghanistan after the war is over.

The U.S. has for years demanded that Pakistan mount a sweeping military offensive in North Waziristan to destroy the Haqqanis, but even if they were so inclined, the fact is that the Pakistani military has only ever been able to control the main roads in North Waziristan. The Pakistani army is incapable of occupying and holding this territory, no matter how much money we offer or how dire the threats we make.
(See whether Pakistan really wants a stable Afghanistan.)

At the core of the problem stands a simple proposition: Pakistan doesn't trust us with Afghanistan  and from Islamabad's perspective, not without cause. We took a strategic decision to invade a country central to their national-security doctrine without seriously consulting them, preferring to think in terms of an Afghanistan of our dreams. Nor did we take into account their strategic interests and the proxies through which they have pursued them. The Soviet Union made the same mistake when it invaded Afghanistan in 1979.

Having failed to prevail a decade later, we now have two choices, neither of them particularly attractive to Washington. We can attempt to destroy the Haqqani base in North Waziristan by invading Pakistan. But to do that effectively would require more troops than we currently have in Afghanistan. Doing so would obviously destroy whatever relations we still have with Pakistan, with profoundly dangerous consequences in Afghanistan and far beyond.

Alternatively, we could hash out a settlement with Pakistan, which would inevitably mean accepting the Haqqanis and easing out Karzai in any political settlement to the conflict. Such a deal would also potentially bring in Afghanistan's other neighbor with real strategic interests in the country  Iran. Iran can be unpredictable, but it's by no means certain it would accept true Pakistani-American collusion in Afghanistan. In the mid-'90s, Iran was all but at war with the Taliban, and if Iran isn't consulted on a settlement, it could play the spoiler.

Accepting Pakistan's postconflict agenda and backing off on the Haqqanis at Karzai's expense is too bitter a pill for Washington to swallow in an election year, so we'll muddle through for another year. But when the U.S. finally leaves, don't be surprised to see the Haqqanis in Kabul.

Baer, a former Middle East CIA field officer, is TIME.com's intelligence columnist and the author of See No Evil and The Devil We Know: Dealing with the New Iranian Superpower.