ISLAMABAD, Pakistan — Sri Lanka plunged into a constitutional crisis Friday evening after the president ousted the prime minister, a move that took the nation by surprise and was denounced as illegal by some government ministers.
Sri Lankans were glued to their television sets Friday after President Maithripala Sirisena dismissed Prime Minister Ranil Wickremesinghe and replaced him with Mahinda Rajapaksa, a popular former leader who was accused of human rights abuses, brazen nepotism and excessively close ties to China when he had governed the country.
The swearing-in ceremony, broadcast live, was a moment of high political drama for Sri Lanka, with Mr. Rajapaksa grinning as he shook Mr. Sirisena’s hand. The men were former political allies until the president broke away from Mr. Rajapaksa’s party to unseat him in 2015 elections.
Fireworks and celebrations broke out across Sri Lanka after the swearing in ceremony, but the capital, Colombo, was uneasy as some cabinet ministers declared the move unconstitutional. Mr. Rajapaksa was sworn in at about 7 p.m. as the chiefs of the military’s navy, air force and army watched in a stately room inside the presidential secretariat.
Cabinet ministers and parliamentarians began defecting to the new government, but it remained unclear how many would ultimately cross over. The country’s courts — seen as weak and politically influenced, were unlikely to rule against President Sirisena.
“I am addressing you as the prime minister of Sri Lanka. I still hold the majority of the house,” Mr. Wickremesinghe said in an address to the nation. “Convene parliament and I will prove it.”
Chaos gripped parts of the capital as supporters of Mr. Rajapaksa stormed the state-owned national television broadcaster and took it off air, a clip later circulated showing a mob shouting at journalists inside the station. Troops were called in to protect the channel’s staff.
Finance Minister Mangala Samaraweera tweeted that Mr. Rajapaksa’s appointment was “unconstitutional and illegal. This is an anti-democratic coup.”
The shake-up appeared to secure the re-ascendance of Mr. Rajapaksa, a man who served as Sri Lanka’s president and prime minister for 10 years until 2015, when the country’s decades-long civil war ended.
Mr. Rajapaksa is expected to win presidential elections next year, partly because Sri Lankans have grown discontent as the economy has sputtered under the current government.
At the height of his power, Mr. Rajapaksa simultaneously served as president and finance minister, among other cabinet positions, while his three brothers served as the defense secretary and ministers of economy and ports. Between them they controlled 80 percent of the national budget and were accused of corruption and major human rights abuses. Their opponents and journalists critical of their governance often disappeared.
Mr. Sirisena’s power play is as much about the clashing personalities of the president and the prime minister as it is about geopolitics. The president and just-ousted prime minister had been political foes until they decided to unite their parties to run against Mr. Rajapaksa in 2015.
India and China have been vying for influence in Sri Lanka, the island nation off India’s southern coast. The country’s ties with China strengthened under Mr. Rajapaksa’s rule, when he borrowed billions of dollars from Beijing’s government to build infrastructure projects, some with little economic purpose.
Western officials worry China could eventually use the strategically located port — which sits at the crossroads of one of the world’s busiest maritime routes — for military purposes, which Beijing and Colombo have denied.
Tension between President Sirisena and his ousted prime minister, Mr. Wickremesinghe, had been building up over the past year and spilled out into the open over the last few weeks. Mr. Sirisena began firing the heads of state institutions not in his purview and stacking them with loyalists.
The tension exploded earlier this month when The Hindu, a major Indian daily, reported that Mr. Sirisena had said to Cabinet members that India’s intelligence service had hatched a plot to assassinate him. Mr. Sirisena denied the report.
Last week, Mr. Wickremesinghe flew to India to meet with his counterpart, Prime Minister Narendra Modi, hoping to smooth relations. Mr. Wickremesinghe then released a summary of the meeting, claiming Mr. Modi had complained that Sri Lanka’s government was stalling its infrastructure investments in the country and was not responding positively to India’s diplomatic overtures.
India’s government was relieved when Mr. Rajapaksa lost elections in 2015, complaining that the former leader had strained ties with New Delhi while moving the country closer to Beijing.
After the elections, India said it would invest in infrastructure projects in Sri Lanka and earlier this year committed to buy an airport in the country’s south next to the Chinese-built seaport. But the airport deal has stalled.
American officials were likely to be unhappy with the government shake up, believing Mr. Rajapaksa is too close to China to keep the country neutral.
Vice President Mike Pence blasted what he called China’s “debt trap diplomacy” earlier this month and singled out Sri Lanka, saying the Chinese-built seaport “may soon become a forward military base for China’s growing blue-water navy.”