Correction: An earlier version of this editorial incorrectly reported that 24 Pakistani troops were killed in an exchange of gunfire along the Afghan-Pakistan border this February. The incident occurred in November 2011. The editorial below has been corrected.

July 16, 2012

TRUCKS ARE trickling across the border between Pakistan and Afghanistan this month, thanks to the latest patch-up between the Obama administration and Islamabad’s fractious menage of generals and elected politicians. The reopening of the supply route will facilitate the massive withdrawal of U.S. troops and equipment from Afghanistan scheduled to take place between now and the end of 2014, and it will allow Pakistan to collect more than $1 billion in deferred compensation from Washington. It heads off an irrevocable breach between the two nations.

Nevertheless, the past seven months, during which Pakistan blocked the supply traffic, have underlined the reality that the deeper alliance that the Obama administration once hoped to forge with this nuclear-armed Muslim nation is out of reach for the foreseeable future. The fault is not inadequate diplomacy by the administration, drone strikes against al-Qaeda targets in Pakistan’s tribal territories or the raid that killed Osama bin Laden at a compound near the heart of the country’s military establishment.

Rather, the insurmountable obstacle is the political dysfunction of Pakistan, a country divided between a feuding, corrupt and insular civilian political elite and a military establishment dependent on terrorist allies and obsessed with unacceptable and unattainable geopolitical ambitions.

Consider the ongoing battle between the government of Asif Ali Zardari of the People’s Party and the Supreme Court, headed by the ambitious Iftikhar Mohammed Chaudhry. The court has already forced the resignation of one People’s Party prime minister, on the grounds that he refused to send a letter to Swiss authorities asking that a corruption investigation of Mr. Zardari be reopened. Now the ambitious Mr. Chaudhry is threatening to oust a second prime minister for the same reason — even though the Swiss probe is unlikely to be renewed whether or not a letter arrives.

While this pointless battle goes on, Pakistanis are rioting over water and power shortages, the economy continues to sink and attacks from Islamic militants based both in Pakistan and in Afghanistan are rising. Meanwhile the Army and its intelligence service hang back, allowing the civilians to mismanage the country while continuing to support their own Islamic militants, who regularly target U.S. troops and installations in Afghanistan and plot terrorism in India. The media, heavily influenced by the military, whip up anti-American sentiment.

The Obama administration rightly rejected the demands of the Zardari government, which wanted to charge an extortionary $5,000 per truck to reopen the supply route. The channel was closed following a November incident in which 24 Pakistani soldiers were killed in an exchange of gunfire with U.S. units along the border. Eventually, Islamabad settled for a renewal of the previous fee of $250 and a half-hearted “apology” from Secretary of State Hillary Rodham Clinton.

Even such an uneasy concord is unlikely with the military, which appears locked into backing a militant Taliban faction as its proxy in Afghanistan and is equally relentless in its attempt to challenge India through the use of terrorist proxies. Until Pakistan develops a democratic civilian government capable of purging that belligerence, the United States will have to settle for a pragmatic combination of buying off Pakistan when it is possible — and containing it when it is not.