(Bloomberg) -- Pakistan Prime Minister Imran Khan won a confidence vote in Parliament, ending a week of political turmoil and giving a boost to his fragile government.

Khan got 178 votes from members of his Tehreek-e-Insaf party and allies in the 342-seat lower house National Assembly, proving the majority, Speaker Asad Qaiser said in televised meeting in Islamabad.

The army-backed former cricket star voluntarily sought the confidence vote after his finance minister Abdul Hafeez Shaikh unexpectedly lost an election for a Senate seat to an opposition-backed candidate on Wednesday, triggering a debate Khan had lost the majority support.

His win may temporarily bring stability to the South Asian nation as its economy recovers from the pandemic-induced contraction with the help of the International Monetary Fund’s $6 billion loan program. With U.S. President Joe Biden urging allies to uphold democracy, stability in Pakistan is an advantage in the region, which is already reeling from a coup in Myanmar.

The strong military, which has an outsized role in Khan’s administration - with a say in matters from foreign policy and security to economic decisions, - may be relieved to see him surviving the vote.

Army chief General Qamar Javed Bajwa “is keen to maintain continuity and show that all is well,” said Burzine Waghmar, a member of the Centre for the Study of Pakistan at SOAS University of London. The army is also “keen to start on a good footing with the Biden administration as well.”

Imran Khan to Seek Pakistan Parliament Vote After Shock Loss

Khan has exerted influence in peace talks with neighboring Afghanistan as U.S. troops prepare to depart, meeting with delegations that have included Taliban militants.

Khan met Bajwa along with the head of the military’s spy agency on Thursday after his finance minister lost the tightly-fought battle for the upper house seat, voted on by the members of the lower house. The meeting with the head of the institution, which has conducted numerous coups and retains tremendous sway over various policies, is believed to have sent a strong message to lawmakers.

The opposition boycotted Saturday’s vote, saying the meeting between the army chief and Khan “gives a wrong message.” The military has ruled the nation for about half of its existence since independence in 1947.

“No party can remain in power without institutional support from the army,” said Amit Ranjan, research fellow at the Institute of South Asian Studies in , National University of Singapore. “Whoever comes next, if Khan loses, also needs support from the army.”

Army Tightens Grip on Pakistan as Imran Khan’s Popularity Wanes

The federal government’s spokesman and the army, which has denied role in politics, had no immediate comment.

Khan alleged 15 or 16 of his lawmakers were bribed by the opposition to vote against the party-backed finance minister in a secret ballot. However, unlike in the Senate, the confidence vote was a public show of strength in the National Assembly, decreasing the chance of lawmakers switching loyalties.

Khan’s woes may not be over even after winning the Parliament vote.

The Senate result has been a boost for the opposition alliance that plans to march on Islamabad on March 26 to topple Khan’s government, two years before he finishes a five-year term. The alliance includes the Pakistan Muslim League-Nawaz led by ex-premier Nawaz Sharif and the Pakistan Peoples Party of former President Asif Ali Zardari.

©2021 Bloomberg L.P.