ISLAMABAD (AP) — Pakistan’s parliament on Monday elected opposition lawmaker Shahbaz Sharif as the new prime minister, following a week of political turmoil that led to the weekend ouster of Premier Imran Khan.

Sharif took the oath of office inside the stately, white marble palace known as the Presidency in a brief ceremony.

But his elevation won’t guarantee a peaceful path forward or solve the country’s many economic problems, including high inflation and a soaring energy crisis.

Sharif, the brother of disgraced former Prime Minister Nawaz Sharif, won with 174 votes after more than 100 lawmakers from Khan’s Pakistan Tehreek-e-Insaf, or Pakistan Justice Party, resigned and walked out of the National Assembly in protest.

Those 174 votes — two more than the required simple majority — are enough to pass laws in the 342-seat assembly. If Khan’s followers take to the streets, as he has vowed, it could create more pressure on lawmakers and deepen the crisis.

Khan, a former cricket star whose conservative Islamist ideology and dogged independence characterized his three years and eight months in office, was ousted early Sunday. He lost a no-confidence vote after being deserted by his party allies and a key coalition partner.

In a show of strength and a precursor to the political uncertainty ahead, Khan rallied hundreds of thousands of supporters in protests Sunday night, describing the new leadership as an “imposed government” that colluded with the U.S. to oust him. His backers marched in cities across Pakistan, waving large party flags and shouted slogans promising to return him to power. The crowds were dominated by youths who make up the backbone of Khan’s supporters.

The political drama began April 3 when Khan sidestepped an initial no-confidence vote demanded by the opposition by dissolving parliament and calling early elections. The opposition, which accuses Khan of economic mismanagement, appealed to the Supreme Court. After four days of deliberations, the court said Khan’s move was illegal and the no-confidence vote went ahead, leading to his ouster.

Khan has demanded early elections — the balloting is not due before August 2023. He has tapped into anti-American sentiment in Pakistan, accusing Washington of conspiring with his opponents to topple him. That conspiracy theory resonates with his youthful base, which often sees the U.S. war on terrorism after 9/11 as unfairly targeting Pakistan.

Khan claims Washington opposes him because of his independent foreign policy favoring China and Russia. He was criticized for a visit he made on Feb. 24 to Moscow, where he met with President Vladimir Putin as Russian tanks rolled into Ukraine.

The U.S. State Department has denied any involvement in Pakistan’s internal politics.

China, which is Pakistan’s key ally and investor, said Monday it would support any government.

“As Pakistan’s close neighbor and iron-clad friend, we sincerely hope that all factions in Pakistan will remain united and work together for national stability and development,” Foreign Ministry spokesperson Zhao Lijian said at a briefing. “I would like to emphasize that no matter how the political situation changes in Pakistan, China will unswervingly adhere to its friendly policy toward Pakistan.”

China is heavily invested in Pakistan in its multibillion-dollar global initiative to link south and central Asia to Beijing.

Pakistan’s longtime rival India also sent congratulations to Sharif, with Indian Prime Minister Narendra Modi saying his country “desires peace and stability.” The two countries have fought three wars, coming dangerously close to a fourth over the disputed Himalayan region of Kashmir, which is divided between the two and claimed by both.

The opposition coalition consists of parties that cross the political divide, from the left to the radically religious. The two largest parties are the Pakistan Muslim League, headed by Sharif, and the Pakistan People’s Party, co-chaired by the son and husband of Benazir Bhutto, the former prime minister who was killed in 2007.

A few wealthy and powerful families have dominated Pakistan’s politics for decades, with power most often alternating between the Sharif and the Bhutto camps. Both political houses have been accused of and at times convicted of widespread corruption. They have dismissed the allegations as being politically motivated.

Nawaz Sharif was unseated by the Supreme Court in 2015 after being convicted of financial irregularities revealed in the so-called Panama Papers — a collection of leaked secret financial documents showing how some of the world’s richest hide their money and involving a global law firm based in Panama. He was disqualified from holding office by the Supreme Court.

Asif Ali Zardari, Bhutto’s husband who served as president of Pakistan after the 2008 election, has spent more than seven years in prison, convicted on corruption charges.

Khan came to power in 2018, promising to break the pattern of family rule in Pakistan, but his opponents said he was elected with help from the powerful military, which has ruled the country for half of its 75-year history.

Nawaz Sharif was also ousted in 1999, in a military coup, and Benazir Bhutto’s government was ousted several times after the military sided with her opposition. In Pakistani politics, where loyalties are often fluid, Bhutto’s fiercest opposition often came from Sharif’s party.

Shahbaz Sharif has served three times as chief minister of Pakistan’s largest, most influential Punjab province, home to 60% of the country’s 220 million people. His son, Hamza, was elected last week as the new chief minister by the Punjab provincial parliament, ousting Khan’s nominee. Khan’s party is challenging that election, and the younger Sharif has yet to be sworn in.

___

Associated Press writer Munir Ahmed in Islamabad contributed.

___

Follow Kathy Gannon on Twitter at https://twitter.com/Kathygannon