Why is the Sri Lankan government in turmoil?

The nation’s president and prime minister come from traditionally opposing parties that formed a surprise coalition in 2015 to oust the then-president Mahinda Rajapakse, who many feared was becoming too powerful.

In the past two years, this ruling coalition has started to fall apart. It is dysfunctional and unpopular with the Sri Lankan public. Since at least February this year, president Maithripala Sirasena has been searching for ways to remove the prime minister, Ranil Wickremasinghe.

On Friday, he found one: suddenly declaring he was firing Wickremasinghe and replacing him with Rajapakse — the same man he had joined forces with Wickremasinghe in 2015 to defeat.

Rajapakse, a colourful and controversial Buddhist nationalist, is probably the most popular politician in Sri Lanka, and some are speculating in Colombo that Sirasena saw an alliance with the former president as his best chance of remaining in power.

Was it legal to have fired Wickremasinghe?

That is for the Sri Lankan supreme court to decide — and a case is yet to be brought — but a close look at the constitution suggests it may not be. In 2015, Sri Lanka amended its constitution to prevent the president from sacking any prime minister unless they had died, resigned or lost the confidence of parliament.

Sirasena has pointed to another constitutional article allows the president to appoint as prime minister any MP who, “in the president’s opinion”, is most likely to command the confidence of parliament.

Constitutional lawyers say Sirasena may have taken this too literally; that his “opinion” should be based on whoever commands the most numbers in parliament.

Wickremasinghe’s party has a plurality of MPs, and on Friday he called for an emergency vote to prove he still had the confidence of parliament. But he was prevented from doing so on Saturday, when Sirasena suddenly suspended parliament until 16 November. This was widely seen as an indication the Sirasena-Rajapakse forces do not believe they would win a parliamentary vote, and need to time to persuade MPs.

So who is prime minister now?

Wickremasinghe has refused to recognise the order firing him and continues to occupy the prime ministerial residence in Colombo, called Temple Trees. The compound has been surrounded by his supporters.

But Sirasena has started stripping Wickremasinghe of staff and privileges. Wickremasinghe has lost his official cars, his office and last night had his security detail reduced from 70 men to ten.

Related: Sri Lanka faces crisis as two stake claim to be lawful prime minister

Rajapakse, meanwhile, is doing everything he can to establish himself as the prime minister. He will start using Wickremasinghe’s office from Monday, has appeared in pictures being saluted by the chief of police, and says he will soon appoint a cabinet.

The deadline of 16 November looms for both men, when parliament is scheduled to reopen and the assembly will likely vote on which man it recognises as the lawful prime minister. Nobody knows for sure, but Rajapakse is thought to have around 100 loyal MPs, and needs 13 more for a majority of the 225-seat assembly.

What are overseas governments saying?

On Monday morning the US urged Sirasena to reconvene parliament immediately. China is thought to be in Rajapakse’s camp: its ambassador paid a “courtesy call” to him on Saturday.

During his 10-year stint in the presidency, Rajapakse had a sour relationship with the west. He oversaw the end of the 27-year Sri Lankan civil war in 2009 through a series of brutal military offensives in which the UN estimates up to 40,000 Tamil civilians died. His tenure was also marred by accusations his security forces were forcibly disappearing, torturing and murdering activists and dissidents.

In that atmosphere, few western governments were willing to help fund Sri Lanka’s reconstruction after the war. So Rajapakse turned to China, which lavished Sri Lanka was enormous loans for infrastructure projects including major air and seaports in Hambantota, the Rajapakse family’s ancestral homeland.

Many of these projects have turned out to be white elephants, forcing Sri Lanka to renegotiate the terms of its loans — and in the case of the Hambantota port, hand over control of the entire property to a Chinese-state owned corporation on a 99-year lease. Some analysts have argued this was China’s plan all along: that Sri Lanka had walked into a debt trap.

The Sirasena-Wickremasinghe coalition came to office in 2015 promises to loosen financial ties with China; in power, it has discovered these contracts are harder to escape than they thought. It has slowly turned back to China in the past two years, albeit while trying to assure the west as well as India, its traditional patron, that they won’t be frozen out.

Could the political standoff turn violent?

A protester was shot dead on Sunday night and two others were injured when a crowd of men affiliated to a pro-Sirasena union mobbed a cabinet minister, Arjuna Ranatunga, as he was trying to enter a government building. One of his guards apparently panicked and fired several rounds at the crowd. The guard has been arrested.

The assessment of most observers, including western diplomats in Colombo, is that Sunday’s shooting was a one-off occurrence. But tensions are extremely high and pro-Sirasena and Rajapakse groups are protesting across the city.

Wickremasinghe’s United National Party is planning its own large protest for Tuesday. All police leave has been cancelled and the army has been deployed in parts of the city as a show of state strength and stability.