Ending the power tussle in Sri Lanka, Mahinda Rajapaksa, who was appointed as prime minister by President Maithripala Sirisena in a controversial move, resigned on Saturday and Ranil Wickremesinghe is likely to take oath as the island nation’s prime minister on Sunday.

Rajapaksa resigned after two crucial Supreme Court decisions made the embattled former strongman’s efforts to cling to premiership untenable.

Pro-Rajapaksa lawmaker Shehan Semasinghe told reporters that the former president signed his resignation letter in a ceremony held in his house in Wijerama in Colombo.

“(Mahinda) Rajapaksa informed the lawmakers of United People’s Freedom Alliance (UPFA) that he has resigned from the post,” Semasinghe said.

Rajapaksa was appointed as prime minister on October 26 by President Sirisena in a controversial move after sacking Prime Minister Wickremesinghe, which plunged the country into an unprecedented constitutional crisis.

The country’s Supreme Court on Thursday unanimously declared that the dissolution of the Sri Lankan Parliament by President Sirisena was “illegal”.

The top court on Friday refused to stay a court order restraining Rajapaksa, 73, from holding the office of prime minister until it fully heard the case next month.

Wickremesinghe’s United National Party (UNP) on Saturday said that President Sirisena has agreed to reinstate him in the post after a discussion with him over the phone on Friday.

“We have heard from the presidential secretariat that our leader will be sworn in as the prime minister tomorrow morning,” UNP general secretary Akila Viraj Kariyawasam said.

The unprecedented political and constitutional stand off which began on October 26 with the sacking of Prime Minister Wickremesinghe appears to end tomorrow with his reinstatement.

Parliamentarian Lakshman Yapa Abeywardena on Friday said Mahinda Rajapaksa, who had ruled Sri Lanka for nearly a decade, decided to step down “in the best interest of the country”.

He claimed Rajapaksa can hold office without resigning but that will only further drag the political turmoil in the country. So the former president decided to step down after the court ruling given on Friday and on Thursday.

Sri Lanka’s Supreme Court on Friday decided that a Court of Appeal order issued against the appointment of Rajapaksa as prime minister and against his Cabinet from holding office will stand.

The appeal filed by Rajapaksa will be taken up for hearing on January 16, 17 and 18.

The top court asked all parties to provide written submissions within three weeks.

According to media reports, a new Cabinet will be sworn in on Monday. The Cabinet will consist of 30 members and include six Sri Lanka Freedom Party (SLFP) parliamentarians.

After his appointment as prime minister, Mahinda Rajapaksa had sought to secure a majority in the 225-member Parliament but failed. President Sirisena then dissolved Parliament and called snap elections on January 5.

However, the Supreme Court overturned his decision and halted the preparations for snap polls.

Most of the countries had not recognised Mahinda Rajapaksa’s government. The global credit rating agencies — the Fitch, the Standard & Poor’s and the Moody’s — had also downgraded Sri Lanka’s rating owing to the current political crisis.