Pakistan's Foreign Minister Shah Mahmood Qureshi was a conspicuously happy man at the February 29 signing ceremony of the peace deal between the United States and the Taliban in Qatar's capital, Doha. Beaming with approval in photographs, he was likened on Twitter to a proud "father of the bride/groom" by several analysts.

Qureshi had good reason to be pleased: Islamabad's policy of pushing a negotiated settlement with the insurgents, the stone in the shoe of its relationship with Washington, was vindicated by the agreement. For more than 10 years, it had withstood increasingly intense pressure from the US for its obstinate refusal to act against or expel self-exiled Taliban leaders based on Pakistani soil, waiting for the White House to come to terms with the futility of the country's longest war.

When the time came, Pakistan's government facilitated negotiations and delivered a boost to President Donald Trump's re-election campaign, earning praise from the mercurial leader during his recent tour of India, barely 20 months after he issued a humiliating public ultimatum to Islamabad to cease providing safe havens to terrorists and severed military aid.

Befittingly, the deal was signed on behalf of the Taliban by its political chief Mullah Abdul Ghani Baradar, who was arrested in Karachi 10 years ago by Pakistan's security services in a joint operation with the CIA.

The US-Taliban deal, which envisages the withdrawal of foreign forces from Afghanistan by the end of April next year, is a win-win for Pakistan. Having played peacemaker, it can no longer be blamed for any delay in intra-Afghan talks.

The onus is now on President Ashraf Ghani and his rival former Chief Executive Abdullah Abdullah to resolve their power struggle, following a tainted election, and present a united front during negotiations with the Taliban on a political settlement. Ghani, in particular, has demonstrated a penchant for brinkmanship by tying his approval for the phased release of 5,000 Taliban prisoners - a key component of the peace deal with the US - to the international recognition of his re-election.

Assuming that the process takes off, Pakistan can realistically look forward to relative stability along its more than 2,000km (1,250 miles) long western border with Afghanistan for the first time since the Soviet invasion of December 1979.

The US-Taliban deal includes a proviso for coordinated counterterror operations against the Khorasan governorate of the ISIL (ISIS) group, ISIL-K, established in eastern Afghanistan in early 2015 by dissident commanders of the Taliban and Pakistan Taliban, known by the acronym TTP, fleeing a decisive military operation in North Waziristan. Since then, they have waged a cross-border hit-and-run campaign against Pakistan's security forces, parallel to a campaign of deadly bombings in Jalalabad and Kabul.

The effectiveness of joint operations was demonstrated in November, when US and Afghan forces, in coordination with specifically-deployed Taliban units and Pakistani forces positioned along the nearby border, deprived ISIL-K forces of their territorial beachhead in Nangarhar province.

Hundreds of surviving fighters have since migrated north to the remote provinces of Kunar and Nurestan, where they continue to be pursued by US warplanes.

As an immediate payoff for its role in the peace process, Pakistan wants decisive coordinated action undertaken to end the threat that they pose to it and the rest of the region at the earliest.

The dismemberment of ISIL-K and its TTP allies, parallel to intra-Afghan talks, would enable Pakistan to expedite the repatriation of the 1.4 million Afghan refugees it still hosts, including Taliban exiles.

It can then seal its recently fenced border with Afghanistan, in effect quashing Kabul's opposition to the boundary drawn up by British colonial cartographers.

In due course, this would immensely relieve the pressure on Pakistan's military forces at a time when tensions with India are their worst in a generation. It deployed about 170,000 troops, roughly one-third of Pakistan's army, to defeat the TTP and secure the border with Afghanistan.

They have mostly remained in place, despite India's aerial incursion a year ago and the persistent skirmishing along in the Line of Control in disputed Kashmir region that has ensued. Pakistan hopes that its cooperation on Afghanistan will convince the US to lean on Trump's good friend, India's Prime Minister Narendra Modi, to prevent another escalation.

For that to happen, Pakistan must keep its promises to repatriate the Taliban, in particular the notorious Haqqani Network faction, and shut down anti-India outfits such as Jaish-e-Muhammad (JeM), which have been inspired by their Afghan brethren's success. It also means that Pakistan should maintain a respectable distance from intra-Afghan talks, to avoid accusations of interference.

Foreign Minister Qureshi has established the parameters of Pakistan's policy by warning against "spoilers", a thinly disguised attack against Ghani's opportunism and India, a long-standing ally of Afghan politicians at odds with Pakistan, like ex-Chief Executive Abdullah. Islamabad also wants Washington to stay out of its disputes with Kabul so that it would be less inclined to resort to anti-Pakistan rhetoric, or to connive with New Delhi.

At the end of this rainbow lies Pakistan's desire to rebuild its on-again, off-again strategic relationship with the US. It is deeply concerned that the suspension of American military aid has compromised its defence capability, and even more worried by Washington's enthusiasm to arm India as a counterbalance to China's growing influence in the Indo-Pacific region.

To achieve that end, Pakistan has to stop employing armed groups to fight on its behalf in its conflicts with other countries. It certainly will not happen overnight, and it hinges hugely on the outcome of the Afghan peace process, but decision-makers in Islamabad know that they will not get a better opportunity to achieve sustainable stability.

The views expressed in this article are the author's own and do not necessarily reflect Al Jazeera's editorial stance.