(Bloomberg) -- Pakistan’s former prime minister Imran Khan ally won a confidence vote as chief minister in the Punjab Assembly, the latest electoral win for the popular opposition leader demanding early general elections.

Chaudhry Parvez Elahi secured 186 votes from lawmakers in the 371-member house, speaker Muhammad Sibtain Khan announced the result in a session that lasted more than an hour after midnight. Prime Minister Shehbaz Sharif’s members boycotted the session and plan to legally contest the voting.

Khan who was ousted as prime minister in April announced to dissolve two of the nation’s four provincial assemblies last month that he holds a majority to force early elections. Khan has said that he will ask chief minister Elahi to dissolve the assembly as soon as he wins the confidence vote. Elahi has so far resisted Khan’s call to dissolve the assembly.

The political uncertainty comes as Pakistan’s economy is facing multiple challenges including a dollar shortage that has led to companies shutting down and a drop in foreign exchange reserves to less than one months of imports amid a delay in its loan program with the International Monetary Fund. Credit rating companies including Moody’s Investors Services have downgraded the nation deeper into junk while its long-term bonds continue to trade at distressed levels.

The voting happened despite the chief minister holding the office temporarily amid a court case. Punjab governor Muhammad Baligh ur Rehman last month sacked the chief minister for refusal to take the vote that was challenged in the court. Rehman withdrew his order after the voting that also ended the legal battle, said Ali Zafar, a lawyer for the chief minister.

(Updates with court case in last paragraph)

©2023 Bloomberg L.P.