Daniel Berehulak / Getty Images Supporters of the Pakistan Muslim League (Nawaz) party celebrate election results with fireworks on May 11, 2013, in Lahore, Pakistan

*This story was updated May 13, 2013

In 1999, Nawaz Sharif was overthrown in a military coup. His vanquisher, General Pervez Musharraf, was broadly welcomed in Pakistan, and later, by the international community. Sharif was first thrown in jail, and later dispatched into exile for seven years. In his absence, some claimed that Sharif’s party — and his political career — were finished. Now, in an astonishing turn of history, Sharif is set to become Pakistan’s Prime Minister for the third time, while his once powerful nemesis Musharraf is under arrest and possibly facing trial for alleged crimes to do with abuse of power. Sharif beat expectations, cruising toward a convincing victory that will allow his Pakistan Muslim League (Nawaz) (PMLN) party to control the national Parliament and hold a two-thirds majority in the provincial parliament of Punjab, Pakistan’s wealthiest and most populous province. As the results became apparent in the early hours of Sunday morning, Sharif supporters spilled out into the streets of Lahore, the capital of Punjab, cheering. Young men whizzed through the streets, their speed lending a flutter to party flags attached at the back. “Look, look who has come? The tiger has come, the tiger has come!” they chanted, referring to Sharif’s election symbol.

If the elections could be boiled down to one issue, it was electricity. Throughout the country, voters listed a litany of their disappointments. They dreaded the near-daily terrorist attacks they suffer, not least during the campaign. At least 130 people were killed during the bloody election campaign, mainly supporters of Pakistan’s secular parties, in attacks on candidates, election rallies and campaign offices. Tales of greed also repulsed Pakistanis. All former ministers of President Asif Ali Zardari’s Pakistan People’s Party (PPP) were voted out in Punjab province.

(PHOTOS: Election Day in Pakistan: Defying Violence, Voters Make History)

But for many voters, their principal concern was the crippling power shortages they endure — sometimes for up to 20 hours a day — and the effect it has on the economy. Economists estimate that Pakistan’s energy crisis shaves off up to 5% growth each year. In big industrial towns like Faisalabad, where Sharif’s party won many seats, factories have been forced to shut down and tens of thousands of workers laid off. If the next government can diminish power cuts substantially, it may be enough to win the next elections. If it fails, it could suffer the fate of its predecessors.

Sharif appealed to voters, particularly in his native Punjab, as a businessman who has experience of governance and who may be able to lift Pakistan’s economy out of its current misery. In a country shifting toward a more conservative direction, Sharif’s social conservatism and religiosity was a plus. In 1997, when he last won an election, Sharif told academic Vali Nasr, he wanted to be “both the [Turkish moderate Islamist leader Necmettin] Erbakan and the [economically minded former Malaysian Prime Minister] Mahathir [Mohamad] of Pakistan.”

It was a disappointing night for former cricket legend Imran Khan, who was mounting an aggressive and high-profile campaign as the candidate for “change.” Despite a flood of publicity, claims of a solid youth vote behind him and a well-financed party infrastructure, he failed to secure the breakthrough he craved, winning around 35 out of 242 seats in Parliament. Khan came second in a vast number of seats, but failed to catch up to Sharif’s galloping tiger. Still, Khan will remain a force in Pakistani politics and could become the leader of the opposition in Parliament while his party, which swept the northwest militancy-wracked province of Khyber Pakhtunkhwa, will form a provincial government there. On Sunday, Khan accepted defeat but said that his party was a victim of polling-day rigging. Several Khan supporters have pointed out incidents of shady electoral practices at polling booths across Lahore. The PPP is licking its wounds, suffering its second-worst defeat ever, but holding on to its stronghold in Sindh province.

(MORE: On Pakistan’s Election Trail, the Old Feudal Elites Struggle for Votes)

Sharif will face three major challenges when he comes to power. He will have to restore electricity and boost the economy. He will have to deal with domestic terrorism. And he will have to work with the U.S., trying to strike a balance between managing relations with Washington while assuaging anti-American sentiment at home. Sharif’s aides say that he is best placed to boost the economy, thanks to his free-market approach. “The best way to deal with the electricity problem is to privatize the energy sector and give the business community a stake in it,” says Khawaja Muhammad Asif, a leading PMLN member.

When it comes to the Pakistani Taliban, Sharif is less clear. In recent years, he has preferred to remain mostly quiet on the threat, as he did during the election campaign. While secular anti-Taliban politicians braved bomb attacks, Sharif and Khan were able to campaign mostly in peace. Sharif has said that he would like to negotiate with the Pakistani Taliban, an approach that is popular among conflict-weary Pakistanis but controversial. Critics point out that all peace deals with the Pakistani Taliban have failed and yielded them more space.

In 2010, Sharif’s younger brother, Shahbaz Sharif, who was chief minister of Punjab, made a controversial appeal to the Pakistani Taliban to spare his province because, like them, his party is “anti-U.S.” During his rule of Punjab, the younger Sharif was also criticized for not doing enough for religious minorities. The Ahmadi Muslim sect suffered its worst-ever attack in 2010. And the province’s Christians have faced two tragedies, earlier this year and in 2009, when a mob of attackers torched clustered colonies in Lahore and Gojra as the police stood by. Many observers are nervous about this trend continuing. Nawaz Sharif’s religious conservatism is what made the Bush Administration wary of him during the Musharraf years. The general’s self-styled “enlightened moderation” was more to their liking than Sharif, who during his second term in power, attempted to crown himself “commander of the faithful.” But in meetings with U.S. officials, Sharif has said he is “pro-American” and keen to work with the U.S. In a meeting with then U.S. ambassador Anne Patterson in 2007, according to a leaked State Department cable, Sharif’s ministers were “disappointed” and “hurt” to read that President Bush said he didn’t know Sharif. They also, according to the cable, “went to great pains to defend Nawaz’s pro-U.S., ‘anti-mullah’ history.” Now, Sharif aides and U.S. officials say both sides are willing to work with each other.

(MORE: Pakistan’s Election Season: When Courting Voters Means Courting Death)

Sharif will also try to establish a new relationship with Pakistan’s powerful generals. Although he emerged as a protégé of General Mohammed Zia ul-Haq, Pakistan’s longest-serving dictator, he ended up clashing with five successive army chiefs until he was ultimately ousted by Musharraf. Sharif was sharply critical of the army’s role in politics during Musharraf’s final years, but has cooled his rhetoric since. “I think the army will want to work with Nawaz Sharif,” says retired Lieut. General Talat Masood, an analyst. The relationship has been repaired over recent years with Sharif’s top aides often meeting army chief General Ashfaq Parvez Kayani.

During his last stint in power, Sharif was capable of destructive confrontations with not just the army, but also rival politicians and critical journalists. Masood says that Sharif has matured over the years: “The time in exile has given him time to reflect and learn.” Surveying the election victory on Sunday, many Pakistanis hope that is true.

MORE: Pakistan’s Election Season Begins With Two Very Different Candidates