PERVEZ MUSHARRAF, Pakistan’s former president, did little to disguise the loathing he felt for his Afghan counterpart, Hamid Karzai. The feeling was probably mutual. Pakistan has long played host to militants who mount cross-border raids in Afghanistan, as well as to senior leaders of the Taliban insurgency. This has made the war waged by the Afghan government and as many as 130,000 NATO troops unwinnable. And, by thwarting negotiations between Taliban leaders and the government in Kabul, the Afghan capital, it has also helped keep peace out of reach.

By contrast, Mr Musharraf’s successor, Asif Ali Zardari, seems to have found in Mr Karzai a new best friend. In Britain this week, sharing a podium with their host, David Cameron, Britain’s prime minister, the two men beamed, clasped hands and pledged what Mr Cameron called “an unprecedented level of co-operation”. They even agreed to work towards a peace agreement with the Taliban within the next six months. This reflects a change in Pakistan’s strategy far more profound than can be explained by Mr Zardari’s more emollient character.

Hopes for peace in six months seem starry-eyed. But at least Pakistan is making big gestures towards “reconciliation” in Afghanistan. In November Afghanistan’s High Peace Council, the body entrusted with seeking a negotiated settlement, visited the Pakistani capital, Islamabad. Pakistan freed 20 Afghan Taliban prisoners, and a peace “road map” was drawn up—and leaked. It gave Pakistan a central role in bringing the Taliban to the negotiating table, which is to be placed in Doha in Qatar. A comprehensive peace process is now a more realistic prospect than at any time since the Taliban were driven from Kabul in 2001.

Years of quarrels, mutual mistrust and casualties brought Pakistan’s relations with America and the government in Kabul to their lowest ebb in late 2011. Yet Pakistan’s ultimate objectives in Afghanistan are not that different from those of NATO, its nominal ally. It has no interest in an endless war to which its own soldiers and civilians fall victim. Only an extremist fringe and a few misguided strategic “realists” hanker after a Taliban restoration in Kabul: that would boost the Pakistani Taliban, whose target is the secular government in Islamabad. It might also revive hopes for a separate “Pushtunistan”, grouping the ethnic Pushtuns on either side of a border, drawn by the British, that Afghanistan has never formally accepted.

What drove Pakistan onto the other side of its own allies’ war is the obsession with India. Its aim has been a future Afghan government that, as a minimum, is not an Indian ally. Such an alliance would “encircle” Pakistan and deprive it of the “strategic depth” it has always felt it needs to deter a hypothetical Indian invasion. At best, the future government would be a loyal Pakistani client. The ISI, Pakistan’s spy service, helped form the Taliban movement that took Kabul in 1996. Pushtun ethnic kinship, along with ties of loyalty and patronage forged over the years, has made the Taliban and other extremist factions, such as the Haqqani network, seem Pakistan’s natural allies in Afghanistan. Now, Pakistan may have decided that if it wants to create a government it can tolerate, talks hold more promise than warmongering.

For several reasons the tacit backing of a Taliban victory may no longer be Pakistan’s best option. The first is that such a victory is unlikely. Any Afghan government left behind after most NATO troops depart in 2014 will probably be able to hold the big northern cities. It will face an insurgency in the south and east. But an interminable civil war is hardly in Pakistan’s interests. Second is the growth of the Pakistani Taliban, a faction of which was driven out of the Swat region of Pakistan in 2009, and has since been squatting in eastern Afghanistan, launching attacks across the border. The Afghan Taliban are unlikely to rein it in.

Pakistan’s improved relations with India and America may also have helped bring it to the table. The usual pattern is for any rapprochement with India to be derailed when a terrorist atrocity or other provocation in India is blamed on Pakistan. That seemed all too likely when the ceasefire over the frontier between the Indian and Pakistani parts of disputed Kashmir broke last month. Three Pakistani and two Indian soldiers were killed; the Indians’ corpses were mutilated. But this has not yet led to a breakdown in relations. And the crisis in ties with America, which led Pakistan to close its Afghan border to NATO supply lorries, has passed. Pakistan is probably pleased to see in John Kerry a new secretary of state whom its leaders know and whose name is on legislation promising Pakistan continuing aid.

Afghan observers know Mr Zardari’s limits. For all that he may soon become the first civilian leader of Pakistan to be replaced by another civilian after a full five-year term, he has paid the price for that by leaving the army free to run security policy. So the most encouraging aspect of the talks in Britain was that the chiefs of both Pakistan’s army and the ISI were there. That does not rule out, however, attacks by elements of the armed forces or the terrorist groups with which they have maintained links, designed to provoke India, Afghanistan or NATO. Terrorists are dangerous partners, not fully under their sponsors’ control.

When push comes to shove

Yet that argument also goes for the Afghan Taliban, whose spokesmen were scathing about the talks in Britain. The biggest question now hanging over the peace talks is whether Pakistan really can lead them to the negotiating table. It has locked up some Taliban leaders, one of whom complained (in comments he later denied) of enduring years of torture. NATO leaders have long argued that some leading Taliban figures living in apparent freedom in Pakistan were in effect hostages, unable to return home even had they wanted to. Pakistan has shown that, without its co-operation, the war in Afghanistan can never end. It has yet to prove it has the power to bring peace.

Economist.com/blogs/banyan