Pakistan’s relations with Afghanistan have been largely characterised by mutual mistrust and devised through a narrow security prism. While it will require considerable effort to end deep-seated animosity, both countries share close ethnic, linguistic, religious and economic ties. Longstanding Afghan migration to the territories that now compose Pakistan makes them an integral part of Pakistani society. Yet, military-devised interventionist policies, based on perceived national security interests, including support for Afghan, mainly Pashtun, proxies, have marred the relationship. The incoming Afghan President Ashraf Ghani Ahmadzai has offered to expand bilateral ties, providing Islamabad fresh opportunities to improve the relationship. Prime Minister Nawaz Sharif has responded positively, but the Pakistani military and civilian leadership’s preferences toward Kabul are diverging further as Afghanistan’s transition draws closer. By recalibrating relations toward economic ties and seeking solutions to the presence of millions of Afghan refugees on its soil, Pakistan could engage more constructively with its neighbour.

Sharif’s top priority, stabilising a faltering economy, will be elusive in the absence of security and hampered by an unstable neighbour; hence his government has reached out to Afghanistan, hoping to reduce bilateral tensions and contribute to post-transition Afghanistan’s stabilisation. The Pakistani military high command, however, continues to hedge its bets, either actively or tacitly supporting a resurgent insurgency, which threatens to undermine Afghanistan’s transition.

Since the Taliban’s 2001 ouster, Afghan insurgents have found safe havens in Pakistan. The command and control of the three main militant groups – Mullah Omar’s Shura (council), Gulbuddin Hekmatyar’s Hizb-e Islami and the al-Qaeda-linked Haq­qani network – are based in and operate from Pakistan. These havens have and could continue to undermine Afghanistan’ efforts to confront the insurgency after the security transition in December 2014.

Pakistan’s interventionist policies are also undermining the peace at home. The Afghan insurgents are aligned with home-grown Pakistani tribal extremists, who in turn are part of a syndicate of sectarian, regional and transnational jihadi groups. With the support of their Afghan counterparts, Pakistani tribal extremists are challenging the state’s writ, particularly in the Federally Administered Tribal Areas (FATA) and Khyber Pakhtunkhwa (KPK) province, bordering on Afghanistan. Military-led initiatives to counter such threats, based on appeasement deals or heavy handed-military operations against Pakistani Taliban factions, have proved ineffective.

The opening of spaces for Pakistani extremists, using their ties with their Afghan counterparts, to attack Pakistani targets from safe havens in Afghanistan, underscores the importance of ending all support, direct or covert, to Afghan proxies. Yet, much depends on the ability of civilian governments in Pakistan to wrest control over national security and foreign policy from the military in a fragile democratic transition.

Since Pakistan’s democratic transition began in 2008, two successive governments have wanted to mend fences with Afghanistan, including through a policy of non-intervention, failing in the face of military intransigence. The first ever transfer of power from one elected government to another, after the May 2013 elections, provided an opening to strengthen civilian control over national security and foreign policy, including in the relationship with Afghanistan. However, ongoing anti-govern­ment demonstrations, begun in August 2014, led by Pakistan Tehreek-i-Insaf (PTI) leader Imran Khan and cleric-cum-politician Tahirul Qadri, have strengthened the military’s ability to extract concessions from Sharif’s Pakistan Muslim League-Nawaz (PML-N) government, particularly regarding one of the most sensitive regional relationships, that with Afghanistan.

Yet, there are still opportunities, not least because of the new government in Kabul that is reaching out to Pakistan, for Sharif to reset the relationship by expanding ties beyond a narrow security focus. Until the democratic transition stabilises, enabling the government to end tacit or direct support for Afghan proxies, Sharif should work with Kabul to expand economic ties, including by upgrading and expanding infrastructure, including road and rail links connecting the two countries, reducing cumbersome security measures, combatting corruption and beginning talks on a free-trade agreement. The two countries would also benefit from easing cross-border movement and providing economic opportunities to their citizens. Improving the relationship would, however, require Pakistan to ease the uncertain and insecure lives of the millions of Afghan refugees on its territory. Islamabad should sign and ratify the 1951 Refugee Convention and its 1967 Protocol. Until it does, it should enact a national law for refugees that codifies long-term protections and rights, and respects the right of non-refoulement.