Mahinda Rajapaksa resigned as Sri Lanka's Prime Minister on Saturday, news agency PTI reported.
Rajapaksa, 73, was appointed as the prime minister on October 26 by President Maithripala Sirisena in a controversial move after sacking Ranil Wickremesinghe, which plunged the island nation into a constitutional crisis.
On Friday, the apex court refused to stay a court order restraining Rajapaksa, 73, from holding the office of Prime Minister until it fully heard the case next month.
Rajapaksa was appointed as the prime minister on October 26 by President Maithripala Sirisena in a controversial move after sacking Ranil Wickremesinghe, which plunged the country into an unprecedented constitutional crisis.
"To ensure stability of the nation, Former President @PresRajapaksa has decided to resign from the Premiership tomorrow after an address to the nation," Rajapaksa's son Namal tweeted.
The Sri Lanka Podujana Peramuna (SLPP) with former president, Sri Lanka Freedom Party (SLFP) and others will "now work to form a broader political coalition with President Sirisena", Namal Rajapaksa, a lawmaker, added.
Wickremesinghe's camp was hopeful that Sirisena would now reinstate him over the weekend after Rajapaksa resigns, effectively ending the political stalemate that plagued the nation for the past seven weeks.
On Thursday, Wickremesinghe, 69, tweeted, "We trust that the President will promptly respect the judgment of the courts. The legislature, judiciary, and the executive are equally important pillars of a democracy and the checks and balances that they provide are crucial to ensuring the sovereignty of its citizens."
There was no immediate reaction from President Sirisena, the architect of the current crisis.
Parliamentarian Lakshman Yapa Abeywardena said Rajapaksa, who 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.
His Cabinet will also stand dissolved, Abeywardena was quoted as saying by the Colombo Gazette.
The apex court's Friday ruling came a day after it unanimously declared that the dissolution of Parliament by President Maithripala Sirisena was "illegal", in a body blow to the embattled leader, whose controversial decisions plunged the island nation into an unprecedented political turmoil.
The Supreme Court 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 apex court asked all parties to provide written submissions within three weeks.
The Appeal Court on December 3 issued notice and an interim order against Rajapaksa and his Government, preventing them from acting as Prime Minister, Cabinet and Deputy Ministers.
The order was issued in a case filed by 122 lawmakers against Rajapaksa and his new government.
Rajapaksa and the members of the purported government filed the appeal against the Court of Appeal's interim injunction that restrained them from functioning in their respective posts.
The United National Front (UNF) said the order means Rajapaksa cannot be Prime Minister and so the former Cabinet must be reinstated.
UNF Parliamentarian Ajith Perera said the President must now appoint Ranil Wickremesinghe as Prime Minister.
Parliamentarians of Wickremesinghe's UNP, Janatha Vimukthi Peramuna (JVP) and Tamil National Alliance on November 23 filed the petition in the Court of Appeal challenging Rajapaksa on continuing to hold the office of Prime Minister after a no-confidence motion was passed in Parliament against him.
Sirisena, after sacking Wickremesinghe, dissolved Parliament and called for a snap election on January 5.
However, the Supreme Court overturned his decision and halted the preparations for snap polls.
Wickremesinghe and Rajapaksa both claim to be the prime ministers with the former claiming that his dismissal is invalid because he still holds a majority in the 225-member Parliament.
Prior to the crisis, Wickramasinghe's UNP had the backing of 106 parliamentarians while Rajapaksa and Sirisena combine had 95 seats.
Rajapaksa has, so far, failed to prove his majority in Parliament.
The President has said that due to sharp personal differences with Wickremesinghe, he would not reappoint him as the Prime Minister.
However, Wickremesinghe's UNP claims that Sirisena will be left with no choice as he would be the man who will command the confidence in the House.
Most of the countries have not recognised 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.
(With PTI inputs)