Image caption The key players: Mahinda Rajapaksa, Maithripala Sirisena and Ranil Wickremesinghe

What is happening in Sri Lanka right now sits somewhere in between House of Cards, Game of Thrones and Shakespeare's darkest Roman plays. It involves a man who betrayed his leader only now to return him to power, an alleged murder plot, and two men laying claim to a grand white mansion that is a symbol of political power.

Here's what you need to know about the constitutional crisis gripping this island nation.

What set off this crisis?

This is complicated because there have been many twists and turns.

Last week Sri Lanka's President Maithripala Sirisena shocked the nation by sacking Prime Minister Ranil Wickremesinghe, dissolving the cabinet, and suspending parliament. He said they hadn't been getting on.

The president then - in what many saw as the bigger surprise - appointed Mahinda Rajapaksa, the man he defeated in the 2015 presidential election, as the new PM.

Mr Rajapaksa led Sri Lanka for a crucial period between 2005 and 2015 and oversaw the controversial end of the country's brutal decades-long civil war. His family dominated Sri Lanka while he was in charge - and members of his inner circle were accused of corruption, war crimes and saddling the country with billions of dollars of debt owed to China.

The family deny wrongdoing, and remain popular, especially in rural areas. But India, the EU and the US are not happy to see his return, correspondents say.

To be clear on the extent of this political U-turn by Sri Lanka's president, you have to go back to the 2015 election. Mr Sirisena was accused of betraying Mr Rajapaksa because even though they belonged to the same political party, he teamed up with Ranil Wickremesinghe to defeat him.

Now that relationship has turned sour and Mr Sirisena has turned back to his old ally-turned-rival-turned-ally again.

So, Rajapaksa has taken office?

Not exactly. Mr Wickremesinghe - the man who was sacked - is refusing to leave Temple Trees, the colonial-era bungalow that is the prime minister's official residence.

He says what the president has done is unconstitutional and that he remains the real prime minister. He wants parliament to be convened so MPs can vote on the matter.

But Mr Sirisena has not yet allowed this to happen - and analysts say that's because he knows no majority yet exists that would endorse Mr Rajapaksa as PM. The Sirisena-Rajapaksa alliance is however trying to turn Wickremesinghe loyalists over to their side with ministries and other concessions. Some in the ousted PM's party allege bribes have been offered, though MPs from Mr Rajapaksa's party deny this.

However the wheels of government have not stopped turning amid this crisis - Mr Rajapaksa has begun work and sworn in a cabinet. He, not Mr Wickremesinghe, is listed as prime minister on the official government website.

Image copyright Getty Images Image caption Mr Rajapaksa has immediately presented himself as the legitimate prime minister

Why are people worried?

The situation is tense and there has already been one deadly confrontation.

Mr Wickremesinghe's supporters have formed a protective crowd at Temple Trees - and Buddhist monks have also been called there to chant prayers, in a possible bid to deter police from using force to remove the sacked PM.

A parliamentary vote could defuse the crisis - but even then, supporters from the losing side could take to the streets in anger.

There is also disquiet in some quarters about the implications of Mahinda Rajapaksa's return to power. Quite apart from the controversial end to the civil war he oversaw an era, which rights groups and UN human rights officials say, saw extrajudicial killings, enforced disappearances and the rise of hardline Buddhist nationalism. He has always denied any connection with illegal activity, but activists fear his return could mean none of the allegations will be properly investigated.

What are the roots of the saga?

It depends on who you talk to.

In a long address to the nation over the weekend, President Sirisena said tensions had been building up between him and his PM for years. He called Mr Wickremesinghe both arrogant and stubborn.

He has also linked him to a controversial central bank bond sale, which is alleged to have led to the loss of 11bn Sri Lankan rupees ($65m; £50m). The president also alleged that a cabinet minister was involved in a plot to kill him and that police had obstructed an investigation.

However, if you were to talk to Mr Wickremesinghe, he would say the roots of this crisis lie entirely in what he sees as the illegitimate actions of Mr Sirisena.

It's true that many analysts say that the coalition government the two formed was likely to collapse because of the fractured relationship.

But the way it happened has taken many by surprise.

Image copyright EPA Image caption Supporters of Mr Wickremesinghe have been gathering outside the official residence he is refusing to leave

So is it even legal?

A number of constitutional experts have said the sacking of Mr Wickremesinghe is not legal. Under the constitution, as amended three years ago, the president does not have the power to remove the prime minister, says constitutional expert Dr Nihal Jayawickrama.

In fact under the 19th Amendment, almost all of the president's executive powers were taken away, he says. This amendment was introduced by both Mr Sirisena and Mr Wickremesinghe.

According to Mr Jayawickrama "only parliament can constitutionally remove a prime minister".

There is a provision that the person most likely to command the confidence of parliament should be named as prime minister, but Mr Wickremesinghe is the leader of the largest party and easily won a no confidence motion earlier this year.

The president has cited a part of the constitution that allows him to appoint a prime minister as the basis for his removal of Mr Wickremesinghe - but some constitutional experts have cast doubt on the validity of that argument.

What is the context?

Sri Lanka is a country that spent decades sunk in a brutal and bloody civil war between the government and the separatist Tamil Tigers, which ended with accusations of human rights atrocities on both sides. Mahinda Rajapaksa was in charge when many accused the government of killing thousands of civilians hemmed into a thin strip of land at the end of the war - the army always denied this.

Eventually the country once again became a top tourist destination and achieved the semblance of stability - but this unprecedented crisis puts that reputation at risk.

The EU has already threatened to stop Sri Lanka's lucrative duty-free trade access to the world's biggest single market if it rows back on commitments to human rights and reconciliation between the majority Sinhalese and minority Tamil communities.