Dexter Filkins’article from Pakistan in the Aug. 23 New York Times raises anew the question that has long haunted even many supporters of the U.S. war in Afghanistan: Have we gotten ourselves into something that’s way over our heads?

Filkins reports that a much-celebrated triumph of U.S.-Pakistani cooperation in combating jihadist terrorism—the joint arrest, earlier this year, of a top Taliban leader in Karachi—was, in fact, a ruse.

It turns out that the arrested Taliban leader, Abdul Ghani Baradar, had been engaged in secret peace talks with Afghan President Hamid Karzai. The Pakistani security agents used the CIA to help them track down Baradar precisely because they wanted to shut down any peace initiative that didn’t involve Pakistan.

In the weeks after Baradar’s arrest, Filkins reports, the security forces detained as many as 22 other Taliban leaders, as a result of which the peace talks ended. Filkins quotes a Pakistani security official as saying, “We picked up Baradar and the others because they were trying to make a deal without us.”

This official also told Filkins that they warned the detained Taliban leaders not to conduct any more talks with the Afghan government without Pakistan’s permission. A “former Western diplomat with long experience in the region” confirmed to Filkins that the ISI—Pakistan’s intelligence service—sent a warning to its Taliban protégés. “The message from the ISI,” he said, “was: ‘No flirting.’ “

So here’s the situation: All the top U.S. officials, from President Barack Obama and the chairman of the Joint Chiefs of Staff on down, have said that winning this war will ultimately require making a deal with “reconcilable” members of the Taliban; yet our main ally in this war—whose assistance is necessary for victory by any definition—has been arresting any Taliban members who try their hand at reconciling.

Back when he was commander of U.S. forces in Iraq, Gen. David Petraeus once asked, “How does this thing end?” He must be asking the same question, with a considerably deeper furrow in his brow, now that he’s the commander in Afghanistan.

And Iraq was the proverbial cakewalk compared with Afghanistan. The difference isn’t merely that Iraqi insurgents could be co-opted because of the threat from foreign jihadists (whereas the Afghan Taliban are homegrown), or that Iraq’s sectarian divisions are basically among Sunni, Shiite, and Kurd (whereas Afghanistan’s schisms are multiple and tribal), or that Iraq is a fairly modern, literate nation (whereas much of Afghanistan is nearly medieval).

The main difference—and the difference that’s at the core of the Pakistan problem—is that the Iraq war was mainly about Iraq, whereas the Afghanistan war is mainly about Pakistan, and Pakistan’s worries are mainly about India.

Pakistani leaders, as is well known, have been reluctant to devote much effort to combating Taliban fighters on the western border with Afghanistan because, in their eyes, the main threat and mortal enemy is the country across their eastern border—India.

As Barnett Rubin, an expert on the region and a professor at New York University, put it in a Foreign Affairs article three years ago:

Pakistan’s military establishment has always approached the various wars in and around Afghanistan as a function of its main institutional and national security interests: first and foremost, balancing India, a country with vastly more people and resources, whose elites, at least in Pakistani eyes, do not fully accept the legitimacy of Pakistan’s existence. [Italics added.]

India, meanwhile, has invested $1.2 billion in various Afghan reconstruction projects and has sent 4,000 workers to help build them, as well as 500 paramilitary troops to protect the workers. India sees good relations with Afghanistan as a gateway to trade across central Asia. Pakistan sees these moves as fulfilling a strategy of encircling Pakistan.

In other words, what makes the Afghanistan war almost forbiddingly complicated (as if it weren’t complicated enough on its own terms) is that Pakistan and India—the region’s main powers and rivals, both armed with nuclear weapons—view it as a proxy war with each other.

Pakistan’s military leaders have a term for their policy toward Afghanistan: “strategic depth.” Keeping a decisive foothold in Afghanistan is, to them, a vital national-security interest; they see it as crucial to preventing India from encircling their country.

This is why the Pakistani military and intelligence service have blocked efforts by Taliban leaders to seek a separate peace with Karzai. It’s not necessarily the “peace” that they mind; it’s the “separate.”

The Pakistanis have instead been pushing Karzai into making a deal with the Taliban faction led by Jalaluddin and Siraj Haqqani, who have led particularly violent incursions into southern Afghanistan from their sanctuary across the border in North Waziristan. U.S. officials are skeptical: The Haqqanis have long had tight links with al-Qaida, and they are thought to be surrogates for the more militant factions of Pakistan’s intelligence service. ISI agents say they can “mediate” a deal between the Haqqanis and Karzai; in fact, for all intents and purposes, they are the Haqqanis.

Still, the idea hasn’t been dismissed out of hand. If the Pakistanis see they can make a deal that preserves their foothold in Afghanistan, on the condition that they rupture all ties with—and turn against—al-Qaida, maybe it’s a deal that, at some point, they’d take.

Whatever happens in these or other talks, the main point is that no deal can be made without Pakistan’s involvement—and no stable, peaceful deal can be made without some sort of détente between Pakistan and India.

The Obama administration is fully aware of the connections. President Obama, Secretary of State Hillary Clinton, and other officials have noted several times that the solution to the conflict must be regional. Barnett Rubin, who wrote the 2007 Foreign Affairs article, is a top adviser to Richard Holbrooke, the U.S. special envoy to Afghanistan and Pakistan. (Though Holbrooke’s relations with Karzai are shaky at best, he is reportedly on good terms with Pakistan’s leaders.)

U.S. officials are trying to persuade Pakistani and Indian leaders to ease their tensions and explore common interests. Pakistan, for instance, persists in refusing to let India trade goods with Afghanistan across Pakistani territory. As a result, India is seeking an alternate trade route through the port of Chabahar in southern Iran. By any rational measure, Pakistanis should see an impending India-Iran alliance as a much bigger threat than expanded India-Afghanistan trade; but, in this sense, they’re not acting in their own best interests.

Knowing the full nature of a problem isn’t the same as knowing how, or having the ability, to solve it—just as, on a more strictly military level, having talented commanders and a smart strategy doesn’t necessarily mean the war will be won. In both cases, lots of factors are simply out of any outsider’s control. And, in this part of the world, we are realizing more and more just how much we are outsiders.

Become a fan of Slate on Facebook. Follow Slate and the Slate Foreign Desk on Twitter.