Nawaz Sharif is the comeback kid of Pakistani politics. With his party’s electoral victory, he is poised to become prime minister for an unprecedented third time. The Sharif odyssey has been remarkable—but now we will see if he can convert his victory into a new beginning for his deeply troubled country and our own tortured relations with it.

The 63-year-old Nawaz Sharif was born into money as the scion of a very wealthy family in Lahore. He entered politics to protect the family’s industry from nationalization. In the 1980s he became a protégé of Pakistan’s third military dictator, Zia ul Huq, and became the dominant politician in the country’s richest and most populous province, the Punjab. In 1990 Sharif was elected prime minister after his great rival, Benazir Bhutto, was booted out by the military.

I first got to know Sharif when I was President George Bush’s Director for South Asia and Persian Gulf Affairs in the White House in the early 1990s. Sharif was America’s partner in trying to wind down the decade-old war in Afghanistan against the Soviet-backed communist government that had outlived the defeat of the Soviet 40th Red Army in 1988, and was still clinging to power in Kabul. Unfortunately, when the communist government finally did collapse in 1992, it only ushered in a vicious civil war among the victorious mujahedin. Pakistan was left to deal with the consequences on its own as America abandoned Afghanistan to its fate. And Sharif lost power in 1993 to Benazir Bhutto.

He was elected back to a second term as prime minister in 1997. A year later he tested Pakistan’s nuclear weapons after India tested its first. As President Clinton’s Special Assistant for Near East and South Asia Affairs, I tried to persuade Sharif not to follow India’s path, but to no avail. In 1999 Sharif’s hand-picked Chief of Army Staff, General Pervez Musharraf, exploded a détente Sharif had arranged with India by starting a war in Kashmir. Normally very shy, Sharif invited himself to the White House on July 4, 1999, to find a way out, and wisely agreed to Clinton’s demand that Pakistan unilaterally abandon the war Musharraf had orchestrated. Sharif’s decision averted a wider—and very possibly nuclear—war.

Sharif fired Musharraf on October 12, 1999, while the general was visiting Sri Lanka. The general refused to step down and instead orchestrated a coup and arrested Sharif. A military court was summoned to try Sharif for treason. Only in Pakistan could a legitimately-elected prime minister be labeled a traitor for firing the country’s top general—a general who Sharif had selected for the job in the first place. Many expected Musharraf to have Sharif executed, just as Zia ul Huq had executed Benazir Bhutto’s father, Zulfikar Bhutto.

Clinton tasked me with saving Sharif’s life. The president believed Sharif did not deserve death, and that it would be a disaster for Pakistan to execute another elected leader after a military coup. I spent a great deal of time arguing for clemency with the Pakistani ambassador in Washington. The ambassador was sympathetic to the argument—but I needed more help. The Saudi ambassador to Washington at the time, Prince Bandar, provided the heavy lifting.

The Kingdom of Saudi Arabia also did not want a repeat of the Zia-Zulfi nightmare. Then Crown Prince Abdallah used the Kingdom’s considerable influence in Pakistan to save Sharif. Saudi Arabia is Pakistan’s closest ally, and has given more financial aid to Pakistan than to any other country in the world. Abdallah asked Musharraf to let Sharif go into exile in Saudi Arabia. As Musharraf later wrote in his memoirs, it was an offer he could not refuse. After 14 months in prison, Sharif went into exile in the Kingdom in December 2000. Few expected him to ever return home.

Now the tables have turned. Sharif has won a massive electoral victory and his long time tormentor, Musharraf, is under arrest in Pakistan after returning from his own exile to run in the elections. Musharraf was ousted by popular pressure in 2008, became a billionaire in exile in London, and then foolishly decided he was Pakistan’s savior this winter and decided to go home to be swept back into power by the people. He miscalculated badly. No one in Pakistan wanted the self-appointed savior, and he is now under house arrest. He faces a number of charges and could be tried for the coup he orchestrated against Sharif. The irony is rich.

But Sharif faces a real challenge over what to do with Musharraf. The general has few supporters even in the army, but the officer corps will be very uncomfortable with the prospect of one of its own serving prison time, or worse. Since many of the senior commanders in the army today, including Chief of Army Staff Ashfaq Parvez Kayani, are former Musharraf protégés who rose with him to power, the question of what to do with Musharraf now is a dangerous challenge. The courts will decide his fate but the next prime minister’s voice will matter.

Deciding how to handle the Musharraf affair is only one of Sharif’s huge challenges. The country is under siege by some of the extremists it nurtured during the wars in Afghanistan. Some 45,000 Pakistanis have died in extremist terrorism since 2001, and violence wracked the election. Sharif has urged a political process to try to end the terror, and has been widely accused of being too soft on the Pakistani Taliban. He has long coddled Pakistan’s most dangerous terrorist group, Lashkar e Tayyiba, which carried out the Mumbai massacre in 2008 and which has its headquarters in Sharif’s home city of Lahore. LeT retains very close links to the army and the intelligence service, the ISI.

Nonetheless, Sharif has also promised to turn a page in Pakistan’s relations with India and has invited Prime Minister Manmohan Singh to his inauguration. As an industrialist billionaire, Sharif knows the Pakistani economy desperately needs more trade and investment from its far more vibrant Indian neighbor. Pakistan’s economy is in shambles, and half the people in the country are under 15 with little hope for a decent education or a good job. Sharif is not obsessed with rivalry with India like his generals; his vision of Pakistan is more about building highways and mass transit than an arms race Pakistan cannot win. In the campaign, he promised that he will build a fast bullet train line linking the port city of Karachi to the northern city of Peshawar. When last in the prime minister’s office, he built a modern highway to link Lahore to Islamabad.

America’s relations with Pakistan are at an all-time low, yet Washington provides huge quantities of military and economic aid to Pakistan: over $25 billion since 2001. We are on opposite sides of the war in Afghanistan where Pakistan and the ISI are the Afghan Taliban’s key ally, even as we depend on Pakistan for the vital supply line that allows us to withdraw our heavy equipment from Afghanistan as we transition out of the country by 2014. Inside Pakistan, our drones fly daily missions looking for al Qaeda— missions Sharif promised to try to halt during the campaign. He did not endorse his rival Imran Khan’s call to shoot down American drones (probably with American-supplied F-16s) but he will face much popular demand to end the drone war.

Two presidents, Bush and Clinton, worked with Sharif with mixed results during his two previous tours as prime minister. Now that the comeback kid of Pakistani politics is on the verge of his third time in the top office, President Barack Obama will need to partner with Sharif. It’s an opportunity Obama needs to make a success.