COLOMBO, Sri Lanka — Sri Lankans on Saturday voted for president after a year of political meltdowns and deadly terrorist attacks, in an election that could return the polarizing Rajapaksa family to power.

The two leading candidates are Gotabaya Rajapaksa, a former defense chief known for his hard-edge leadership, and Sajith Premadasa, the son of a former president who was killed during the country’s long civil war.

A decade ago, Mr. Rajapaksa and his brother, Mahinda Rajapaksa, then Sri Lanka’s president, were credited with ending that civil war, but at a brutal cost: thousands of civilian deaths and the propagation of a muscular Sinhalese Buddhist nationalism that persists today.

In a country split along ethnic, class and religious lines, divisions have only been intensified by the wave of bombings on Easter Sunday in April by a Muslim militant group claiming loyalty to the Islamic State. Hundreds of people were killed, mostly at churches and hotels, in attacks that shattered a tenuous postwar peace and raised fears of retribution against innocent Muslims.