Updated at 10:40 a.m. ET

Sri Lankan President Mahinda Rajapaksa, who presided over the end of a prolonged and brutal civil war that divided the country for decades, has suffered a narrow election defeat at the hands of a former ally and Cabinet minister, Maithripala Sirisena.

Sirisena, who defected from the ruling party in November to challenge an increasingly unpopular Rajapaksa, won 51.2 percent of the vote in national elections in the island-nation.

In a tweet, Rajapaksa, who won 47.5 percent of the vote, promised a peaceful transition of power.

Rajapaksa's supporters credit him with ending a quarter-century-long conflict between predominately Hindu ethnic Tamils and the country's majority, and largely Buddhist, Sinhalese. The civil war claimed between 60,000 and 100,000 lives from 1983 to 2009.

However, the BBC says that Rajpaksa's critics accuse him of becoming increasingly authoritarian and corrupt.

"Mr Sirisena had already received promises of support from Tamil and Muslim leaders before the election."But the result shows he also picked up a significant portion of the majority Sinhalese vote, most of whom solidly supported Mr Rajapaksa in previous elections."

The Associated Press, too, cites Rajapaksa's "unpopularity among this island's ethnic and religious minorities, as well as grumbling among the Sinhalese majority about his growing power," as an explanation for the upset.

According to the AP:

"Sirisena, 63 and a longtime politician, called on his supporters to remain peaceful in the wake of victory, telling them at a gathering at the Election Commission that they shouldn't 'even hurt anybody's feelings.'"'The honor of this victory is in your peaceful conduct,' he said, thanking Rajapaksa for ensuring the transition had so far gone smoothly."

Bloomberg says the election of Sirisena could be a blow to China, which has leaned heavily on its good relations with Rajapaksa in its plans to expand dominance in the region: "The result, considered improbable just two months ago, risks disrupting President Xi Jinping's moves to increase China's presence in the Indian Ocean. China has invested heavily in Sri Lanka over the past decade and supported Rajapaksa in the face of U.S.-led inquiries into human rights abuses allegedly committed during the end of [the] civil war."

Copyright 2016 NPR. To see more, visit http://www.npr.org/.