Mahinda Rajapaksa has resigned as Sri Lanka’s prime minister, seven weeks after he was appointed in a surprise move that sparked a political crisis.
Mr Rajapaksa, Sri Lanka’s former president, signed his resignation letter in a ceremony at his house.
His son, Namal, told the BBC his father had quit to ensure national stability.
The resignation could bring to an end a nearly two-month-long power struggle that has dented confidence in Sri Lanka’s stability.
In October, President Maithripala Sirisena sacked then prime minister Ranil Wickremesinghe, replacing him with Mr Rajapaksa.
Mr Wickremesinghe is expected to return to office on Sunday.
His party’s spokesman Harin Fernando told the BBC: “The president has agreed to swear in Ranil Wickremesinghe as Prime Minister tomorrow at 10 am.”
He said this would end the political deadlock, remarking that the the country and its economy had suffered “huge damage” since the crisis began 50 days ago.
On Thursday, the Supreme Court said Mr Sirisena had acted illegally in November by dissolving parliament and calling snap polls with nearly two years to go until elections were due.
Throughout the crisis, Mr Wickremesinghe has always maintained he is the rightful PM.
The crisis, which has provoked brawls in parliament and sparked large protests, has been closely watched by regional power India, as well as the US, China and European Union.
Mr Rajapaksa, who dominated Sri Lankan politics for a decade until 2015, has an uneasy relationship with the West over the bloody end to the country’s civil war in 2009, when thousands of civilians were killed. Both government forces and the Tamil Tiger separatist rebels are accused of grave human rights abuses and crimes.
On Wednesday, parliament passed a vote of confidence in Ranil Wickremesinghe as prime minister.
His party and its allies have a simple majority in parliament – and have argued from the beginning that President Sirisena’s actions were unconstitutional.
What are the roots of the saga?
Mr Sirisena was once a party ally of Mr Rajapaksa, and served in his government.
But in 2015, he teamed up with Ranil Wickremesinghe to defeat him in an election and the pair went on to form a coalition government.
However the relationship between president and prime minister turned sour and Mr Sirisena in October turned on Mr Wickremesinghe, sacking him in favour of Mr Rajapaksa, his old ally-turned-rival-turned-ally.
He called Mr Wickremesinghe arrogant and 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.