Sri Lankan prime minister Ranil Wickremesinghe has been sworn in as acting president after his predecessor Gotabaya Rajapaksa fled to Singapore and resigned following months of protests over the country's financial meltdown.
AFP looks at how cash-strapped Sri Lanka ended up in its worst-ever economic crisis, and what comes next in its complicated, corrupt and sometimes violent political system.
Why did Rajapaksa flee?
Sri Lanka's financial woes were triggered by the coronavirus pandemic but exacerbated by mismanagement under Rajapaksa's government.
The country has been unable to finance even the most essential imports since late last year, and has since defaulted on its debt.
Discontent had been mounting for months over severe food and fuel shortages, record inflation and lengthy power cuts.
Even Rajapaksa's closest allies began abandoning him, and when protesters overran his official residence in Colombo last weekend, he was forced to flee to a navy base in fear for his life. He escaped first to the Maldives, then travelled on to Singapore.
Wasn't Rajapaksa a popular leader?
Rajapaksa was dubbed "The Terminator" for ruthlessly crushing Tamil rebels as head of the defence ministry during his elder brother Mahinda's presidency between 2005 and 2015.
He was loved by his Sinhala Buddhist majority, but loathed by Tamils and Muslims who saw him as a war criminal, a racist and an oppressor of minorities.
When inflation crossed 50 percent, and with four out of five people forced to skip meals because of acute shortages, the ethnically divided nation united in its opposition to Rajapaksa.
Why an acting president?
Rajapaksa formally quit on July 14, just 32 months into his five-year term, with prime minister Wickremesinghe automatically elevated as the acting leader under the country's constitution.
Wickremesinghe is serving as a stop-gap until the 225-seat parliament elects one of its members to lead the country for the balance of Rajapaksa's term. The legislature's Speaker Mahinda Yapa Abeywardana has scheduled the vote for Wednesday.
How does the election work?
The 225 MPs will rank the candidates in order of preference in a secret ballot.
Candidates need more than half the vote to be elected. If no-one crosses the threshold on first preferences, the candidate with the lowest support will be eliminated and their votes distributed according to second preferences, and so on until someone reaches the mark.
Who are the likely candidates?
Acting President Wickremesinghe, the pro-Western six-time prime minister, is the front runner after he secured the support of the Rajapaksas' SLPP, which is still the largest single bloc in parliament.
The SLPP has more than 100 seats and if party discipline holds, Wickremesinghe is almost certain to be elected.
But the party is fractured so that unity is not guaranteed, and SLPP dissident Dullas Alahapperuma, 63, a former media minister, is a serious challenger.
Sajith Premadasa, 55, the main opposition leader, announced Friday that he would also enter the fray.
A possible fourth contender is former army chief Sarath Fonseka, 71, a nemesis of the Rajapaksa family.
The secret ballot gives MPs a freer hand than an open poll, and previous elections have seen allegations of bribes offered and accepted in exchange for votes.
During a constitutional crisis in October 2018, some MPs said they had been offered $3.5 million in cash and apartments abroad for their support.
What does this mean for IMF talks?
Despite their differences, Sri Lanka's political parties are united in their support for ongoing talks with the International Monetary Fund, with Wickremesinghe saying a bailout is urgently needed.
Sri Lanka declared itself bankrupt in mid-April when the government defaulted on its $51 billion foreign debt.
But the political crisis has interrupted the negotiations, and the IMF said Thursday that it hoped the unrest would be resolved soon so they could resume.
No political party in the current parliament has a clear majority, and even if the country could afford to hold a fresh election, Tamil legislator Dharmalingam Sithadthan pointed out that a strong mandate was not always a guarantee of stability or success.
"We had Gotabaya with a record 6.9 million votes and what did he do?" Sithadthan told AFP. "He was a total failure."