ISLAMABAD (Reuters) - Pakistani lawmakers elected former cricket legend Imran Khan prime minister on Friday and he pledged to bring to justice “all those who have robbed this country” through corruption.

FILE PHOTO: Cricket star-turned-politician Imran Khan, chairman of Pakistan Tehreek-e-Insaf (PTI), speaks after voting in the general election in Islamabad, July 25, 2018. REUTERS/Athit Perawongmetha/File Photo

Parliament’s move cleared the way for the 65-year-old Khan to set up a coalition government and his first major task will be to avert a brewing economic crisis after his party swept to election victory on July 25.

Khan saw his party sweep to victory in a July 25 general election promising to fight corruption and lift millions of people out of poverty.

Pakistan has been plagued by boom-and-bust cycles and military coups since independence in 1947, as well as by Islamist militant violence in more recent years.

Khan, a firebrand nationalist, has promised to create millions of jobs and build world-class hospitals and school systems in the mainly-Muslim country of 208 million people.

Among his first challenges will be to decide whether to request an International Monetary Fund (IMF) bailout to ease currency pressures, or seek support from China and risk deepening Pakistan’s economic dependence on its neighbor.

“I want to thank the people and I want to thank God for giving me the opportunity to bring change,” Khan, wearing a black waistcoat over traditional white shalwar kameez robes, said in a speech in parliament.

“First of all we have to do strict accountability,” Khan added. “Those who have robbed this country, I will hold each and every one of you accountable.”

In a sign of Pakistan’s bitter political divisions, opposition lawmakers surrounded Khan and disrupted his speech throughout by shouting “thief, thief Imran Khan” and “puppet”.

Khan’s election was only the second democratic transfer of power since Pakistan’s 1947 independence, and came at a time when relations with on-off ally the United States are fraying over alleged Pakistani support for militants waging war in Afghanistan. Islamabad denies aiding insurgents.

Khan’s Pakistan Tehreek-e-Insaf (PTI) party holds 151 of the 342 seats in the lower chamber of parliament, short of a majority, but is expected to form a coalition government with smaller parties.

Slideshow ( 2 images )

In Friday’s lower house vote, Khan garnered 176 votes to defeat Shehbaz Sharif from the outgoing Pakistan Muslim League-Nawaz (PML-N) party, who won 96 votes. Khan, who will be sworn in on Saturday, has yet to announce his cabinet.

LEGISLATIVE HURDLES

His success in the election ended decades of political dominance by two dynastic powerhouses, the PML-N of three-time premier Nawaz Sharif, and the Pakistan Peoples Party (PPP), founded and led by the Bhutto family.

But Khan will face a battle to push through his ambitious reforms and legislative agenda due to the thin majority in the National Assembly. The Senate, parliament’s upper chamber, is controlled by the opposition.

“Legislative business will be difficult for him,” said Raza Ahmad Rumi, editor of the Daily Times newspaper.

Opposition parties allege election rigging and say Khan’s path to power was made easier by the tacit support of the powerful military, which has ruled Pakistan for nearly half its history. The army and Khan’s PTI deny any collusion.

“The whole nation has rejected this election,” said Shehbaz Sharif, demanding an investigation of electoral irregularities.

Murtaza Abbasi, a PML-N lawmaker, said in parliament Khan was “brought here by aliens”, a euphemism for the military.

Khan shot back that he had “struggled 22 years” to become premier. “No military dictator raised me. I got here on my own.”

How Khan addresses historic civil-military tensions that have dogged successive governments could define his term.

No Pakistani premier has ever completed a five-year term in office, including Sharif, whose most recent stint in power was ended by the Supreme Court last year.

Sharif, who was jailed over corruption accusations several weeks before the election, saw his second stint in power ended by a military coup in 1999.

CURRENCY CRISIS

The economy is likely to preoccupy Khan’s first few months in office, with his administration facing a battle to reduce a ballooning current account gap and a high fiscal deficit, which shot up to 6.8 percent of GDP in the 12 months to end of June.

To deal with current account pressures Pakistan’s central bank has devalued the rupee four times since December, while interest rates have been hiked three times this year.

A sharp increase in oil prices - Pakistan imports about 80 percent of oil needs - has contributed to a current account deficit that widened by 43 percent to $18 billion in the fiscal year that ended June 30.

China has also provided billions of dollars in loans to shore up Pakistan’s foreign currency reserves, which stand at just over $10.1 billion - enough to cover two months of imports.

Earlier this week Asad Umar, widely expected to be appointed Finance Minister, told the English-language Dawn newspaper that Pakistan turning to the IMF would be a “fallback option” and that all other possibilities are being explored.