The end of American involvement in Afghanistan and the change in leadership in Pakistan presents the United States with an opportunity to reset its long-troubled relationship with the world’s fifth most populous country. President Joe Biden should initiate a high-level dialogue with new Prime Minister Shahbaz Sharif, who will be in power for up to a year before the next election is held.

For most of the last 40 years, American policy toward Pakistan revolved around our interests in the wars in Afghanistan. In the 1980s, we partnered with the military dictator Zia ul-Haq to arm the Afghan mujahideen against the Soviets. Then we sought Pakistani cooperation to fight al-Qaida and the Taliban, often with mixed results. Karachi port was crucial in both wars to get supplies to our Afghan allies and NATO forces in Afghanistan. Pursuing these wars was Washington’s top priority, edging out all other issues.

Because our policy was focused on fighting wars in Afghanistan, our primary partners in Pakistan were the intelligence service and the military. Less attention was devoted to the civilian government. Unintentionally this helped destabilize the always fraught civil-military balance in Pakistan, bolstering Pakistan’s military at the expense of its civilian governments.

The withdrawal of American and NATO forces from Afghanistan last August, a badly flawed operation, has essentially freed up American policy toward this important nuclear-armed Muslim country of 243 million people. Now Washington can engage with Islamabad without prioritizing Afghanistan issues at the expense of our broader interests in regional stability with India and China, encouraging development in South Asia, and supporting the strengthening of the elected democratic forces in Pakistan. America also has an interest in balancing somewhat the influence of China, Pakistan’s closest ally, on decisionmaking in Islamabad.

The Biden administration, and in particular the White House, has given Pakistan a relative cold shoulder to date — irked by the war in Afghanistan ending with a Taliban takeover and ostensibly with then-Prime Minister Imran Khan publicly criticizing the U.S. as it happened; more broadly, Pakistan has simply not been high on the priority list of an administration aiming to counter China via its relationships in the Indo-Pacific and now focused on Russia’s war on Ukraine.

Biden did not call Khan while he was prime minister. Last fall, we argued he should. Khan in turn declined to attend Biden’s Summit for Democracy. The White House should call Shahbaz Sharif. Sharif is a three-time former chief minister of Punjab, Pakistan’s largest and most prosperous province, and brother of three-time former Prime Minister Nawaz Sharif. The Sharifs have been marred by corruption allegations, key to Imran Khan’s arguments against them, but they are also pragmatic men eager to develop Pakistan’s infrastructure and economy. (One of us, Bruce, has known them for over 30 years.) They have generally refrained from foreign adventures and conflict with India. Their (belated) opposition to the reckless military operation in Kargil in 1999 is what led to the overthrow of Nawaz’s administration later in 1999.

On the other hand, Imran Khan is an ideologue. He relied on anti-American rhetoric both in his rise to power as well as in his recent fall, denouncing alleged American interference in Pakistani politics this spring first to try to stay in power and now to try to get back in charge. He has been an outspoken critic of American operations against al-Qaida and the Taliban.

Unfortunately, American warnings that supporting the Afghan Taliban would lead to a stronger threat from the Pakistani Taliban to Pakistan have proven to be all too accurate. Pakistan’s clashes with both have intensified in recent days. The Afghan Taliban has ignored Pakistan’s entreaties to control their Pakistani Taliban allies.

The Afghan people could be a beneficiary of improved relations between America and Pakistan. Washington has shown no real leverage on the new regime in Kabul. Afghan girls are barred from attending secondary school and increasingly constrained in the workplace. Islamabad has more influence in Kabul than any outside player, albeit within limits. For example, it controls the importation of oil to its neighbor. Pakistan has been at the forefront of calling for engagement with the Taliban regime. Working with Islamabad may help ease the misery of the Afghan people over time. It’s worth exploring.

The Sharif government has a moderate military leadership to work with in the months ahead. Chief of Army Staff General Qamar Javed Bajwa has openly criticized Russia’s invasion of Ukraine, a marked shift from Khan’s posture of “neutrality” on the war. Khan was coincidentally in Moscow when the invasion began. Given that his relationship with the Biden administration was non-existent, Khan’s relationship with Russian President Vladimir Putin — who called him three times since August — and Chinese President Xi Jinping looked like a leaning away from America toward Russia and China. With his reliance on a U.S. conspiracy narrative as his government was about to fall, he solidified that position. On the other hand, Bajwa has spoken publicly about improving relations with America, as has Shahbaz Sharif. They will have to walk a delicate balance in engaging with the United States given Khan’s U.S. conspiracy narrative, which the army and Sharif have rebuffed but which Khan’s supporters buy wholesale.

The opportunity for the Biden administration for this engagement is not open ended. Shahbaz Sharif inherits a weak economy which is now his primary problem, and his runway is limited. Imran Khan, meanwhile, is determined to get back in power. His support is substantial; he has led huge rallies in Pakistan’s major cities, relying on demagoguery and anti-American rhetoric. He is trying to undermine the new government’s legitimacy by calling it an “imported government” and railing about the corruption cases against its members. His party has resigned from parliament. In the end, the prize for both the Sharifs and Khan is the next election. Pakistan’s politics is increasingly uncertain; it’s an urgent time to open a dialogue.

A major priority for sustained presidential engagement with Pakistan should be to strengthen the democratic process in the second-largest Muslim country in the world. No elected prime minister has served out five years in office; too often the military has intervened to bring down the elected government. By underscoring American support for civilian rule by engaging primarily with Sharif and his foreign minister, Hina Rabbani Khar, Biden’s team would belatedly make Pakistan a part of the president’s policy of strengthening democracy against autocracy. This should usher in a new era of stability in the U.S.-Pakistan relationship, that has seen too many highs and lows — essentially because the relationship has been predicated on America’s goals in Afghanistan. That would mean engaging with civilian governments regardless of which leader is in power — which will benefit Pakistan itself and the U.S.-Pakistan relationship in the long-run.

In terms of what should be on the immediate agenda, first would be the notion that the relationship with Pakistan can no longer be focused solely on security, though that would be one necessary dimension, with the Taliban in power in Afghanistan, a rise in attacks by the Islamic State Khorasan group and the Pakistani Taliban, and given Islamabad’s nuclear arsenal and difficult relationship with New Delhi. Another aspect of the agenda could be to explore avenues for strengthening the economic relationship in a way that uses Pakistan’s untapped economic potential (ultimately to both Pakistan and America’s benefit), for instance with Pakistan’s small but growing tech sector. An important effect is that this gives Pakistan something other than the China-Pakistan Economic Corridor to look to in terms of investment; a stronger economy also loosens the military’s hold on the country. It’s a big opportunity to fundamentally alter U.S.-Pakistan relations.