Sri Lanka’s supreme court has rejected an attempt by the president to dismiss parliament and hold snap elections, leaving the country without a prime minister or cabinet and extending a political crisis that has paralysed the nation for more than six weeks.

The court in Colombo ruled that Maithripala Sirisena’s order to dismiss parliament, issued on 9 November, was unconstitutional.

The unanimous decision by the country’s top judges also leaves Sri Lanka without a budget for 2019. Lawmakers have warned that public sector employees could cease being paid from the beginning of next month.

The ruling prolongs an impasse that started on 26 October, when Sirisena suddenly announced he had dismissed the country’s prime minister, Ranil Wickremesinghe.

Wickremesinghe declared the dismissal an “undemocratic coup” and refused to vacate the prime ministerial residence for the man Sirisena appointed to replace him, the country’s former leader Mahinda Rajapaksa.

Rajapaksa has been unable to rally enough MPs in the country’s parliament to confirm his prime ministership, and Sirisena has refused to reappoint Wickremesinghe, whom he claims was stubborn and arrogant and allowed corruption to flourish.

Sirisena had tried calling an election to break the deadlock but after Thursday’s decision must continue negotiating with Wickremesinghe and other parliamentary leaders.

Tensions have run high among politicians, who have openly sparred in the country’s parliament. Supporters of Rajapaksa have attacked opponents on the assembly floor with chairs, copies of the country’s constitution and water mixed with chilli powder.

A member of Wickremesinghe’s party was pictured during one brawl last month brandishing a steel letter opener.

Fireworks were let off in front of the supreme court building in Colombo shortly after 5.15pm local time when Thursday’s decision was announced.

“We trust that the president will promptly respect the judgment of the courts,” Wickremesinghe tweeted shortly after the verdict. “The legislature, judiciary, and the executive are equally important pillars of a democracy and the checks and balances that they provide are crucial to ensuring the sovereignty of its citizens.”

Sources close to Wickremesinghe’s United National Party (UNP) said they had received an invitation from Sirisena to meet later on Thursday evening.

Namal Rajapaksa, a member of his father Mahinda’s party, said his group would convene tonight to discuss their next move.

“Even though we do not agree with this decision, there is no other court we can go to,” he said. “We will be meeting with President Maithripala Sirisena and Mahinda Rajapaksa at the head and we will decide our next course of action.”

Abraham Sumanthiran, a Tamil MP and one of the lawyers who argued before the court in favour of rejecting the president’s order, said the court had reached a decision “that will no doubt go down in history as one of the most important”.

There were scuffles outside the country’s state newspaper where UNP supporters had allegedly tried to force their way inside. Rajapaksa supporters had entered the same building in October in the aftermath of his appointment as prime minister and allegedly supervised the newspaper’s coverage of the event.

The past month and a half has been a significant test for the institutions of what Sri Lankans boast is Asia’s oldest democracy.

Rajapaksa was ousted in 2015 by an unlikely coalition formed by Sirisena and Wickremesinghe, who hail from traditionally opposing parties. Among the few issues that united them was fear that Rajapaksa’s government had grown too authoritarian and corrupt.

When the pair took office, they amended the constitution to strip powers from the presidency, hoping to limit any future leaders who tried to amass the kind of power Rajapaksa and his family had come to wield over his 10-year presidency.

Yet it was this same 19th amendment that Sirisena appears to have contravened in past weeks by trying to summarily dismiss Wickremesinghe.

The pair – Wickremesinghe an urbane, business-friendly lawyer, Sirisena the socialist son of a farming family – have struggled to reconcile differing policy views and their coalition has stagnated and grown unpopular in the past 18 months. Their personal relationship has also festered: Sirisena said last month he could not tolerate working with Wickremesinghe again, “even for one hour”.

Sirisena was thought to be facing certain defeat at the 2020 presidential polls when he hastily announced the prime ministerial appointment of Rajapaksa, a Buddhist nationalist strongman whose former administration was marred by allegations of rampant human rights abuses including forced disappearances.

But the attempted leadership switch has been repeatedly stymied by Sri Lanka’s other branches of government. Most lawmakers in parliament, where loyalties frequently shift, have refused to join Rajapaksa’s coalition. Legacy media outlets that rallied around Rajapaksa in the hours after he was sworn in have been drowned out by a hive of critical journalists, lawyers and policy analysts on social media.

And on Thursday the supreme court – an institution once regarded as unwilling to wade into sensitive political issues – elected to stop Sirisena in his tracks and force him to end the crisis by constitutional means.

The bench is scheduled to deliver another important ruling on Friday on whether Rajapaksa is permitted to exercise prime ministerial powers without the support of a majority of MPs in parliament.