ISLAMABAD — For years, Pakistan has been accused of playing a double game in Afghanistan — harboring suicide bombers, hosting Taliban insurgents and seeking to destabilize its poorer neighbor while paying lip service to efforts to settle the Afghan war through negotiations.

But when U.S. and Taliban officials signed an agreement in Qatar on Feb. 29, paving the way for the withdrawal of U.S. troops and power-sharing talks between Taliban and Afghan leaders, Pakistan hailed the breakthrough. It also hoped to take some of the credit, having freed a jailed Taliban leader who then became the group’s chief negotiator.

Instead, the deal quickly hit several snags, including a bitter struggle among Afghan political rivals and a Taliban dispute with President Ashraf Ghani over the promised release of thousands of insurgent prisoners. Taliban attacks resumed after a brief partial truce, and the follow-up talks were put on hold. Now, Pakistanis say they are worried that the crisis could unleash the same kind of violence and refugee exodus that followed the withdrawal of Soviet troops in 1989.

“Sadly, it appears as if history is repeating itself in Afghanistan,” the editors of Dawn newspaper wrote Wednesday, recounting how the power vacuum and civil war of the post-Soviet era gave rise to the Taliban takeover in 1996. Some of the most notorious figures from that era are involved in the current political fight. “Unfortunately,” the editors wrote, “it appears that the Afghan power brokers have learned nothing.”

Numerous international experts portray Pakistan, which once backed the Taliban regime, as still favoring the insurgents over the Afghan government led by Ghani, which has been highly suspicious of Pakistan and has built a close relationship with Pakistan’s archrival, India. They suggest that regardless of whether intra-Afghan talks succeed, Pakistan will come out a winner.

“As a nation, Pakistan is better off with its Afghan neighbor at peace,” said Michael Kugelman, a regional expert at the Woodrow Wilson International Center for Scholars in Washington. “But Islamabad would derive strategic benefits from an Afghanistan that remains at war, because its Taliban partner only gets stronger and India’s ability to operate there is diminished.”

Pakistani officials take strong exception to that analysis, insisting that they are sincere about wanting peace and that they are far more worried about external “spoilers” sabotaging it. They also insist that Pakistan, having been besieged by domestic Islamist terrorism for years, has no desire to see a resurgence of such violence.

“It is in Pakistan’s enlightened self-interest to see peace and stability come to Afghanistan,” Pakistani Foreign Minister Shah Mahmood Qureshi, said in an interview here Thursday. “We have no favorites” in the planned power-sharing dialogue among Afghan groups, he said. “We have no desire to interfere, and we have no other agenda. We will work with whatever arrangement the talks produce.”

Pakistani experts, though, said they were aghast at the spectacle that unfolded last week in Kabul after U.S. officials were unable to patch up relations between Ghani and his top rival in the September presidential election, Abdullah Abdullah. Declaring that he was the real winner, Abdullah vowed to form a parallel government, and on Monday the two men held rival swearing-in ceremonies just blocks apart in Kabul.

Pakistan congratulated Ghani, whose ceremony was attended by U.S. and European diplomats.

But officials here fear that the split between the rival Afghan leaders will exacerbate ethnic and political tensions, making it impossible for the government to form a negotiating team and threatening to undo years of effort to settle a war that has taken tens of thousands of lives since 2001. By comparison, they noted, the Taliban has been united and serious in its approach.

“On the Taliban side, there is one leader. On the other side is a roomful of people who all want to be equal and have their interests looked after,” said Ayaz Muhammad Wazir, a retired Pakistani ambassador. “For them to forgo their personal egos in favor of the national interest is a very tall order.” He called the squabble in Kabul the “most striking” obstacle to peace.

Kugelman and other American analysts said that despite the dire expressions of concern here about a cross-border spillover of Afghan turmoil, Pakistan stands to benefit no matter what becomes of the peace and power-sharing talks. They said Pakistan still sees the Taliban as a more reliable ally than the fractious Afghan political elite and still sees India as a mortal enemy it can never trust.

“If there’s a peace deal, the likely result would be a political settlement with the Taliban enjoying some degree of power,” Kugelman said. “If the peace process never takes off or falls apart, and especially if American troops leave Afghanistan, then the Taliban would be strengthened in a big way.”

Despite their past alliances, though, many Pakistanis share Afghan concerns over whether the Taliban has changed enough to co-govern a country that has modernized during two decades of democratic rule. The insurgents insist that the future government be fully Islamic, the constitution thrown out and women’s rights allowed only within Islamic rules.

“We must avoid beating the drum,” Riaz Mohammad Khan, a longtime Pakistani diplomat and Afghanistan specialist, told a conference here Wednesday. Pakistan may have good relations with the Taliban, but it should do nothing to “rankle” the Ghani government or “evoke suspicions,” he said. “Anything that brings peace and stability is to our benefit.”