Pakistan's parliament on Monday elected Shehbaz Sharif as Prime Minister after a week-long constitutional crisis that climaxed on Sunday when his predecessor Imran Khan lost a no-confidence vote.
Shehbaz, 70, who has a reputation domestically as an effective administrator more than as a politician, is the younger brother of three-time prime minister Nawaz Sharif.
Analysts say Shehbaz, unlike Nawaz, enjoys amicable relations with Pakistan's military, which traditionally controls foreign and defence policy in the nuclear-armed nation of 220 million people.
The younger Sharif emerged as the leader of a united opposition to topple Khan, a former cricket star who has claimed that the United States was behind his downfall, which Washington has denied.
Nawaz Sharif was barred by the Supreme Court in 2017 from holding public office and subsequently went abroad for medical treatment after serving just a few months of a 10-year jail sentence for corruption charges.
Just minutes before the vote, legislators from Khan's party resigned en masse from the lower house of parliament in protest at the expected formation of a government by his political opponents.
"We are announcing we are all resigning," Shah Mahmood Qureshi, former foreign minister and vice president of Khan's party, said in a speech in the assembly.
Khan's Pakistan Tehreek-e-Insaf (PTI) party had submitted papers nominating Qureshi as its candidate for prime minister.
The mass resignations will require fresh by-elections in well over 100 seats.
"There can't be any bigger insult to this country," Khan, ousted in a no-confidence vote by the same assembly in the early hours of Sunday, told reporters on Monday on the prospect of Sharif being elected.
No elected prime minister has completed a full term in the nuclear-armed nation since it won independence from colonial power Great Britain in 1947, though Khan is the first to be removed by a no-confidence vote.
The military has ruled the country of 220 million people for almost half its nearly 75-year history. It viewed Khan and his conservative agenda favourably when he won election in 2018. But that support waned after a falling-out over the appointment of military intelligence chief and economic troubles that last week led to the largest interest rate rise in decades.
Khan remained defiant following his defeat in parliament.
Thousands of his supporters in several cities held protests against his ousting that went on until Monday's early hours.