Now Sharif faces the monumental task of leading the country of 180 million people out of its sea of problems, including widespread power outages and militant attacks.
Sharif received 244 votes in the 342-seat parliament, returning him to the prime minister's office for an unprecedented third time. Sharif, who was deposed in a military coup in 1999, will later Wednesday be sworn in by the president.
The vote in the National Assembly was something of a formality after Sharif's party's victory in the May 11 polls.
Yet it marked a turnaround for the 63-year-old Sharif, who served two terms in the 1990s before being ousted from office in the 1999 military coup. He spent nearly eight years in exile, mostly in Saudi Arabia, and five years in the opposition before regaining the prime minister's office.
During a speech to lawmakers after his election, Sharif emphasized that fixing the country's economy — specifically the blackouts, unemployment and corruption — was his top priority.
"I will do my best to change the fate of the people and Pakistan," he said.
The former ruling Pakistan People's Party and the party of cricketer-turned-politician Imran Khan also fielded candidates against Sharif for the vote in parliament but the outcome was never in question.
But if the vote was easy, solving the problems that Pakistan faces will not be. As the new premier, Sharif will face a mountain of problems, including militant attacks and an unprecedented power crisis.
Over the last five years of the previous administration, power outages — some as long as 20 hours — have plagued the country. People suffer through sweltering summers, and in recent years gas shortages in the winter have left people unable to heat their houses.
Companies struggle to find a way to run businesses without a reliable source of electricity.
Sharif and his team of advisors, well aware that they were elected on the expectation that they'd solve this issue, have been meeting continuously with officials from the country's power-related industries and interim government officials from affected ministries.
"We will do whatever is possible to overcome the energy crisis," said Sharif's brother, Shehbaz Sharif, while speaking to reporters in the capital of Islamabad. Sharif's brother is expected to be elected Thursday as chief minister of Punjab province, the PML-N's stronghold.
When it comes to ties with the U.S., Sharif has sent mixed messages about what type of relationship he'll pursue.
The U.S. and Pakistan have differed in the past over how to best pursue peace in Afghanistan and how to deal with militants in Pakistan's tribal areas.
During an interview with reporters shortly after his election, Sharif said he wants good relations with the United States but criticized American drone strikes on militants as a violation of the country's sovereignty.
After an American drone strike killed the deputy commander of the Pakistani Taliban, Waliur Rehman, last Wednesday, Sharif expressed "deep disappointment" in the strike. The statement called the strike a violation of Pakistan's sovereignty and international law.
Also on HuffPost