Although foreign policy hardly figures in election campaigns ahead of the July 25 in Pakistan, there are serious challenges that the next government will face on the external front.
Growing estrangement with the United States, the ongoing war in Afghanistan, tension with India and relations with China will be the major foreign policy issues the new government will have to deal with.
Tensions with the US
The US-Pakistan alliance that emerged after 9/11 seems to have come full circle: The turbulent relations between the two countries have come almost to a breaking point.
The downturn that began following the US Navy Seal raid on Osama bin Laden's house in May 2011 and the air attack on a Pakistani border post that killed more than a dozen soldiers and officers at the end of the same year has not come to an end. It has transformed relations from a strategic alliance to more of a transactional arrangement.
Both civil and military aid from the US was curtailed during former President Barack Obama's second term. Now the residual transactional relationship has also come under strain after sitting President Donald Trump announced his administration's South Asia policy earlier this year and suspended military assistance. Like its predecessors, the Trump administration demands unquestioned cooperation, ignoring Islamabad's interests.
Washington has linked aid to Pakistan taking action against the Afghan Taliban groups operating from its border areas and if it does not get what it wants, it could declare the country a terrorist haven.
Surely such radical moves cannot succeed. Still, they would put greater diplomatic pressure on Islamabad to crack down on suspected militant sanctuaries and take action against the Taliban leadership allegedly operating from Pakistan.
At the same time, the US' leverage over Islamabad has weakened over the years, with Pakistan diversifying its relations with other regional powers particularly its growing strategic partnership with China. Yet a complete breakdown of relations between Washington and Islamabad is not an option.
Dealing with this tense situation will be a very serious challenge to the new Pakistani leadership, almost comparable to what the government faced in the aftermath of the 9/11 attacks.
Afghanistan and the Taliban insurgency
Afghanistan remains the most serious challenge for the new government. Resumption of bilateral talks seems to have broken the ice and reopened a window of opportunity for Islamabad and Kabul to build an atmosphere of mutual trust and put ties on a more stable footing. There is already de-escalation in tensions as both sides have recognised the need for close cooperation to deal with a common threat.
What is particularly encouraging is the lowering of hostile rhetoric thus paving the way for a conducive environment in which rational discussions on critical issues affecting the two countries can be held. There is, indeed, strong reason for optimism but it would require a greater effort by both sides to remove the major sources of tension, not an easy task given the huge baggage of mutual distrust and certain adverse internal and external factors.
The recent meeting in Kabul took the discussions forward with more concrete suggestions for evolving a common strategy to deal with cross-border sanctuaries that have been the biggest cause of tension between the two countries. The most important outcome of the meeting was the assurances given by Afghan leaders that the Afghan forces backed by additional US troops are now in a better position to tackle the Pakistani Taliban and other militant sanctuaries in their territory.
Indeed, it is going to be a big test for the Afghan forces. Both the US and Afghanistan insist that sanctuaries on Pakistani soil have enabled the Afghan Taliban to sustain and expand insurgent operations in Afghanistan over the past 16 years.
It will also be a much bigger challenge for Pakistan's new leadership to eliminate the alleged Afghan Taliban safe havens inside Pakistan and take action against the Haqqani network, as the Pakistani establishment continues to deny their presence there.
The growing intensity of insurgent attacks in Afghanistan and reluctance of the Taliban to enter into peace negotiation remain a major point of conflict between Kabul and Islamabad.
It is apparent that the Taliban leadership may have demonstrated some flexibility in agreeing to a short ceasefire during this year's Eid al-Fitr perhaps on the persuasion of Pakistan and China, but there is no indication yet of the militia accepting Afghan President Ashraf Ghani's offer for peace talks.
However, the dynamics generated by the Eid ceasefire may have opened a window of opportunity. Pakistan has offered to facilitate peace negotiations, while it is not clear whether it has any influence with the Taliban leadership. The best thing for Pakistan is to encourage the Afghan Taliban to directly negotiate with Kabul without Islamabad taking any responsibility.
Undoubtedly, improvement in bilateral relations between Kabul and Islamabad is a very encouraging development. But, given the existing wall of mutual distrust, there is still a long way to go for the relationship to become more meaningful.
Pakistan's Afghan policy would basically remain under the domain of the security establishment and the elected civilian government is likely to follow the line. However, post-election political stability in the country would be key to making positive progress on relations with Kabul.
India and China
Perhaps the biggest foreign policy challenge for the new government would be to figure out how to normalise relations with New Delhi and manage business with Beijing.
Tensions between the two nuclear-armed neighbours has heightened over the past few years with escalation of hostilities on the Line of Control dividing Indian and Pakistani sides of Kashmir. That has also led to the suspension of bilateral negotiations between the two countries.
Former Prime Minister Nawaz Sharif did take some initiative to improve relations with New Delhi, but he could not make much headway because of domestic resistance and Indian Prime Minister Narendra Modi's intransigence.
Sharif's Indian policy was also one of the reasons for his falling out with the military. Almost all mainstream political parties support better relations with their eastern neighbour, but security and the Kashmir issue remain a major hurdle to a breakthrough. Also given that India is having a general election next year, there is no hope of any major development, although any initiative from New Delhi would be welcomed by the Pakistani political elite and the military.
Relations with China will also remain stable. The growing China-Pakistan axis reflects Asia's emerging geopolitics and realignment of forces. Pakistan's distancing from the US and heightening tension with India has led Islamabad to increase its reliance on China, its "all-weather friend". The growing ties between the US and India is also a factor that is further consolidating the China-Pakistan axis.
The China-Pakistan Economic Corridor (CPEC) has brought a dimensional shift in the two countries' relations at a time of significant geopolitical change. But while it promises wide-ranging benefits for infrastructure development and economic growth in Pakistan, a number of important challenges remain to be overcome if the project is to be sustainable and produce long-term benefits for Pakistanis.
Although China has an extremely positive image among the general population, the lack of transparency on the terms of various CPEC projects has generated a growing scepticism in Pakistan's civil society and business circles. A major challenge for the new government is to negotiate better terms with the Chinese firms so as to reap maximum benefit from their investments.
The underlying issue for Pakistan's leadership is how to implement the CPEC programme in a way that removes structural imbalances and puts the economy on a sustainable growth trajectory.
In short, Pakistan finds itself in complex foreign policy circumstances and once the new government is sworn in, managing the country's foreign relations will be one of its biggest challenges.
The views expressed in this article are the author's own and do not necessarily reflect Al Jazeera's editorial stance.