COLOMBO, Sri Lanka >> The Marxist candidate, Anura Kumara Dissanayake, was elected president of Sri Lanka on Sunday, riding a wave of popular anger at the established political order that ran the South Asian nation’s economy into the ground.

The remarkable turnaround for Dissanayake, after he had won only 3% of the vote in 2019, lifts his half-century-old leftist party, Janatha Vimukthi Peramuna, to the center of a political landscape shattered by widespread protests two years ago. The popular outpouring of anger culminated in the toppling of the strongman president, Gotabaya Rajapaksa, who fled the capital city, Colombo, on a navy ship as protesters jumped into his pool and fried snacks in his kitchen.

Dissanayake, 55, had in recent years led a rebranding effort of an organization once known for deadly insurrections: building a large coalition, softening its radical positions and pitching it as the alternative to the deeply rooted politics of patronage that has brought only hardship to many of the island nation’s roughly 23 million people.

“The people have placed their trust in me and my political movement,” Dissanayake said Sunday evening after the election commission officially declared him the winner. “Everyone — those who voted and didn’t vote for me — we have a responsibility to take this country forward.”

Dissanayake received 5,740,179 votes, followed by opposition leader Sajith Premadasa, with 4,530,902, Election Commission data showed.

In a sign of how enormous a swing it is in the island nation’s political landscape, Dissanayake’s immediate challenge will be forming his Cabinet. In Sri Lanka’s system, Cabinet ministers must come from the parliament, where his party has only three seats.

His officials said the new president has constitutional options to oversee the work of the ministries while he calls for new parliamentary elections in the coming months, in which his party will have the momentum.

“Parliament will be dissolved because this parliament already lost the mandate,” said Bimal Rathnayake, a member the political bureau of the new ruling party.

While congratulations and concessions trickled in Sunday morning as the overnight vote count continued, Dissanayake’s official victory had to wait until late in the day as the results required another round of counting that included voters’ second and third choices.

In Sri Lanka’s ranked-choice election system, voters can mark one candidate on their ballot or list three candidates in order of preference. If no candidate gets 50% or more of the vote, a second round of counting factors in the preferences of voters whose first choice did not make it to the top two.

At the end of a peaceful and orderly vote Saturday, the government had made a surprise announcement of an overnight curfew as the counting continued. But a statement of support from Dissanayake’s camp suggested it was a coordinated effort to prevent violence, rather than anything sinister.

There was also praise from leaders of the country’s minority groups, as well as from activists for an election campaign that, unlike divisive past campaigns, had happened largely “without recourse to racial or religious chauvinism.”

It is the first time a presidential election in Sri Lanka has appeared genuinely multipronged, in contrast to a history of direct competition between coalitions formed by the two parties that have dominated ever since the nation became a republic in 1972.

While officially more than 30 candidates were contesting, the majority of the votes were split among three front-runners.

The popular protest movement that forced the powerful Rajapaksa clan out of power in 2022 threw the political landscape wide open, the anger reshaping the dynamics down to the local level. While Gotabaya Rajapaksa had put accusations of war crimes during the country’s bloody civil war behind him to win a handsome mandate in 2019, his management of the economy led to his downfall: The country ran out of foreign exchange for imports, as people lined up for fuel and food.

Ranil Wickremesinghe, the 75-year-old political survivor who stepped in as interim president after Rajapaksa fled the country when protesters surrounded his home, has helped stabilize the country and negotiated a bailout package with the International Monetary Fund.

But Wickremesinghe was also trailing far behind in Saturday’s vote, with his roughly 17% of the votes putting him in third place — a sign of anger over his austerity measures that have pinched the poor hard, and of his lasting public image as part of the discredited old guard.

This report includes information from the Associated Press.