ISTANBUL — Public schools are closing, on little or no notice, and being replaced by religious schools. Exams are scrapped by presidential whim. Tens of thousands of public teachers have been fired. Outside religious groups are teaching in schools, without parental consent.

The battle over how to shape Turkey’s next generation has become a tumultuous issue for President Recep Tayyip Erdogan, as he seeks re-election on Sunday in a vote that is shaping up as a referendum on his deepening imprint on the country after 15 years at the helm.

Mr. Erdogan has already chipped away at Turkey’s democratic institutions, purging the courts and civil service of suspected opponents, bringing the media to heel, and leaving in place a state of emergency after a failed coup in 2016 that has added a new level of precariousness to the campaign.

His opponents fear that his re-election to a newly empowered presidency after constitutional changes last year will give Mr. Erdogan almost unchecked authority to push his agenda even further and fundamentally alter Turkish society.