Sharif’s election brings to a close a week-long constitutional confrontation that climaxed on Sunday when Khan lost a no-confidence vote, although the nuclear-armed nation is likely to remain prone to political and economic turbulence.
Sharif, 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 country of 220 million people.
After the vote, Sharif vowed to tackle an economic malaise that has seen the rupee hit an all-time low and the central bank hike rates by its largest amount in decades last week.
“If we have to save the sinking boat, what we all need is hard work, and unity, unity and unity,” he said in his maiden speech to parliament.
“We are beginning a new era of development today.”
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 foes.
“We are announcing we are all resigning,” Shah Mahmood Qureshi, former foreign minister and vice president of Khan’s party, told the assembly. The mass resignations will require fresh by-elections in well over 100 seats.
Khan’s Pakistan Tehreek-e-Insaf (PTI) party had submitted papers nominating Qureshi as its candidate for prime minister.
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.
Sharif said in an interview last week good relations with the United States were critical for Pakistan for better or for worse, in stark contrast to Khan’s prickly ties to Washington.
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.
“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.
(Reporting by Asif Shahzad, Syed Raza Hassan and Gibran Naiyyar Peshimam in Islamabad; Additional reporting by Jibran Ahmad in Peshawar and Gul Yousafzai in Quetta; Writing by Alasdair Pal; Editing by Simon Cameron-Moore, William Maclean)