ISLAMABAD - Pakistan's parliament elected Nawaz Sharif as prime minister on Wednesday, marking a historic transfer of power in a country that has undergone three military coups.

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.

Related on HuffPost:

Loading Slideshow...
  • Former prime minister and leader of Pakistan Muslim League-N party, Nawaz Sharif, gestures while speaking to members of the media at his residence in Lahore, Pakistan, Monday, May 13, 2013. (AP Photo/K.M. Chaudary)

  • Party supporters of the former Pakistani leader Nawaz Sharif dance and celebrate after his victory in front of one of his homes in Lahore on May 12, 2013. (ROBERTO SCHMIDT/AFP/Getty Images)

  • A Pakistani girl, right, who was displaced with her family from Pakistan's tribal areas due to fighting between militants and the army, walks past an election banner showing former prime minister and leader of Pakistan Muslim League-N, Nawaz Sharif, and other members of his party, pasted on a rickshaw parked in a poor neighborhood on the outskirts of Islamabad, Pakistan, Monday, May 13, 2013. (AP Photo/Muhammed Muheisen)

  • Supporters of Pakistan's cricketer-turned-politician Imran Khan block the main Murree road of Rawalpindi, Pakistan, Monday, May 13, 2013. Supporters of Pakistan Tehreek-e-Insaf headed by Khan, observed a nation-wide protests against the alleged rigging in May 11 elections and demanded re-poll in certain constituencies. (AP Photo/B.K. Bangash)

  • Pakistan's incoming prime minister Nawaz Sharif (2L) meets with journalists at his farm house in Raiwind on the outskirts of Lahore on May 13, 2013. (ROBERTO SCHMIDT/AFP/Getty Images)

  • Pakistan's incoming prime minister Nawaz Sharif (C) offers a table full of food to journalists after a press conference at his farm house in Raiwind on the outskirts of Lahore on May 13, 2013. (ROBERTO SCHMIDT/AFP/Getty Images)

  • Supporters of Pakistani politician Imran Khan stage a protest against alleged vote rigging in Lahore on May 13, 2013. (Arif Ali/AFP/Getty Images)

  • Party supporters of the former Pakistani leader Nawaz Sharif dance and celebrate after his victory in front of one of his homes in Lahore on May 12, 2013. (ROBERTO SCHMIDT/AFP/Getty Images)

  • Supporters of former Pakistani prime minister and head of the Pakistan Muslim League-N (PML-N), Nawaz Sharif celebrate the victory of their party a day after landmark general elections, in Lahore on May 12, 2013. (Arif Ali/AFP/Getty Images)

  • Supporters of former Pakistani Prime Minister and head of the Pakistan Muslim League-N (PML-N), Nawaz Sharif, celebrate with fireworks the victory of their party a day after landmark general elections, in Lahore, on May 12, 2013. (Arif Ali/AFP/Getty Images)

  • Supporters of Pakistan Muslim League-N (PMLN) celebrate election results with fireworks in front of a party office, late evening on May 11, 2013 in Lahore, Pakistan. (Photo by Daniel Berehulak/Getty Images)

  • Supporters of Pakistan Muslim League-N (PMLN) celebrate election results in front of a party office late evening on May 11, 2013 in Lahore, Pakistan. (Photo by Daniel Berehulak/Getty Images)

  • A Pakistani woman casts her ballot at a polling station on the outskirts of Islamabad, Pakistan, Saturday, May 11, 2013. (AP Photo/Muhammed Muheisen)

  • Pakistani women line up to enter a polling station and cast their ballots, on the outskirts of Islamabad, Pakistan, Saturday, May 11, 2013. (AP Photo/Muhammed Muheisen)

  • Supporters of Pakistani politician and former cricketer Imran Khan carry their party flags as they take part in a rally in Rawalpindi on May 12, 2013. (AAMIR QURESHI/AFP/Getty Images)

  • A Pakistani election official empties a ballot box at the end of polling in Rawalpindi on May 11, 2013. (FAROOQ NAEEM/AFP/Getty Images)

  • Pakistani election workers count ballots at a polling station on May 11, 2013 in the Old City of Lahore, Pakistan. (Photo by Daniel Berehulak/Getty Images)

  • Former Pakistani prime minister Nawaz Sharif (L) casts his vote at a polling station in Lahore on May 11, 2013. (Arif Ali/AFP/Getty Images)

  • A Pakistani election official empties a ballot box at the end of polling in Islamabad on May 11, 2013. (AAMIR QURESHI/AFP/Getty Images)