Sri Lanka's Prime Minister Ranil Wickremesinghe speaks to supporters at the prime minister's official residence in Colombo on December 16.
CNN  — 

Sri Lanka Prime Minister Ranil Wickremesinghe has been reinstated by President Maithripala Sirisena, the man who sacked him two months ago and plunged the island nation into chaos.

Sirisena administered the oath that restored Wickremesinghe to office on Sunday.

“We thank the citizens of the country who fought the illegal seizure of power and ensured that Democracy was restored,” Wickremsinghe’s United National Party wrote in a post on Twitter shortly after he was sworn in.

In late October Sirisena dismissed the cabinet and replaced Wickremesinghe with former strongman President Mahinda Rajapaksa, who led the campaign to crush Tamil Tiger guerrillas in 2009. Rajapaksa stepped down from the post on Saturday.

The country’s Supreme Court had ruled on Thursday that Sirisena’s firing of the Prime Minister violated the constitution.

At the time of the sacking, Sirisena said he made the decision due to “political problems (and) economic troubles” which he believed only Rajapaksa could solve.

The decision created a constitutional crisis, with Wickremesinghe insisting he was still Prime Minister, leading to mass protests in the capital Colombo.

Sri Lanka’s institutions had fought back in the wake of the President’s decision, with Parliament passing a no-confidence motion in Rajapaksa in November and declaring his appointment “void and invalid.”

Sirisena had attempted to dissolve Parliament to avoid the vote but the Supreme Court overturned that decision as well.

The chaos has damaged Sri Lanka’s economic standing, with Fitch Ratings downgrading it from ‘B+’ to ‘B’ in December due to the political upheaval.