Updated

Sri Lankan President Maithripala Sirisena sacked the country's prime minister and his Cabinet on Friday and replaced him with a former strongman, an aide said.

Sirisena Sirisena informed Ranil Wickremesinghe that he was being replaced by his former nemesis, Mahinda Rajapaksa, the aide said.

The aide, Mahinda Amaraweera, said Rajapaksa had the majority needed in the 225-member Parliament to legitimize Sirisena's action and to run a stable government.

Wickremeisnghe, however, told reporters that he had no intention of leaving his post.

"I have the majority. I will function as the prime minister. I will remain as the prime minister," he said.

According to the constitution, the president has the right to appoint someone who he thinks has a majority in Parliament.

"At the moment, there is a constitutional crisis — two persons each claiming to be the prime minister," said Jehan Perera, executive director of the nonpartisan National Peace Council of Sri Lanka. "What the president now should do immediately is to summon Parliament and have a vote. That's the democratic way to resolve this crisis."

Rajapaksa ruled Sri Lanka as president for nine years beginning in 2005, accumulating immense power and popularity among the country's majority ethnic Sinhalese after overseeing the military's brutal defeat of ethnic Tamil rebels in 2009, ending a 25-year civil war. Some supporters hailed him as a king and a savior.

But he was also criticized for failing to allow an investigation into alleged war crimes by the military. Under his government, dozens of journalists were killed, abducted and tortured and some fled the country fearing for their lives. He lost a bid for re-election in 2015 amid mounting allegations of corruption and nepotism. His return to power as prime minister could signal that Sri Lanka is sliding back to an era of violence against political opponents, critics and journalists, observers said.

Sirisena's ouster of Wickremeisnghe ends an uneasy coalition government that was formed by their two bitterly opposed political parties on a pledge to tackle corruption.

Sirisena, who was health minister under Rajapaksa, and Wickremesinghe joined forces to defeat Rajapaksa in the 2015 election. Sirisena was elected president largely through votes from Wickremesinghe's party.

After winning the presidency as a neutral candidate, Sirisena accepted an offer from Rajapaksa to take over his Sri Lanka Freedom Party. Since then, party rivalries have simmered within the government, with Rajapaksa leading a splinter Freedom Party group.

Members of Wickremesinghe's government called Friday's move a coup.

"The appointment of Mahinda Rajapaksa as prime minister is unconstitutional and illegal. This is an undemocratic coup," Mangala Samaraweera, the finance minister of the outgoing government, said on his Facebook page.

A private TV network loyal to Rajapaksa televised him being sworn in as the new prime minister.

Rajapaksa then visited a Buddhist temple in Colombo — a typical rite of passage for new leaders to receive religious blessings.

Approximately 200 supporters, some carrying photographs of him, gathered outside Rajapaksa's home late Friday to congratulate him.

One of them, Amal Prasanna, said the move was "totally unexpected" but that she was happy that Rajapaksa had returned.

"We expect economic development and a good future for our children," she said.

Traditionally Sirisena's Sri Lanka Freedom Party has espoused left-of-center views and opposed economic liberalization, while Wickremesinghe's United National Party leans right and has championed reforms to open up Sri Lanka's economy. His government also pledged justice for those accused of committing atrocities in Sri Lanka's civil war during Rajapaksa's rule.

Wickremesinghe had survived a no-confidence motion in Parliament in April which was brought by supporters of Rajapaksa.

The main allegation against Wickremesinghe involved his appointment of a Singaporean as the central bank governor who is now accused of leaking inside information to benefit his son-in-law in a treasury bond sale.