Pakistani lawmakers elected former cricket legend Imran Khan prime minister on Friday, paving the way for him to form a coalition government whose first major task will be to avert a brewing economic crisis.
Khan, 65, 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 militant violence in more recent years.
Khan, a firebrand nationalist, has promised to create millions of jobs and build world-class hospital 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 neighbour.
"Imran Khan got 176 votes," Asad Qaiser, the parliament speaker, said in confirming Khan's victory over rival candidate, Shehbaz Sharif of Pakistan Muslim League-Nawaz (PMLN), who garnered 96 votes.
In a sign of the bitter political divisions roiling Pakistan, opposition lawmakers surrounded Khan and shouted "thief, thief Imran Khan" after he was elected premier.
Khan's Pakistan Tehreek-e-Insaf (PTI) party holds 151 seats in the 342-seat lower chamber of parliament, short of a majority, but is expected to form a coalition government with smaller parties.
Khan, who will be sworn-in on Saturday, has yet to announce his cabinet.
His success in the election ended decades of political dominance by two dynastic powerhouses, the Pakistan Muslim League-Nawaz (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 Khan's path to power was made easier by tacit support of Pakistan's powerful military, which has ruled the country for nearly half its history.
The army and Khan's PTI deny any collusion.
Murtaza Abbasi, a PML-N lawmaker, said in parliament Khan was "brought here by aliens", a euphemism for the military. Other opposition lawmakers shouted "puppet prime minister".
How Khan addresses historic civil-military tensions that have dogged successive governments could define his term, analysts say.
No Pakistani premier has ever completed a five-year term in office, including three-time premier Sharif, whose most recent stint in power was ended by the Supreme Court last year.
Sharif, who was jailed over corruption accusations weeks before the election, saw his second stint in power ended by a military coup in 1999.