ISTANBUL — When Semra dropped off her 13-year-old daughter for the first day of high school, she had to fight back tears as she entered the dimly lit basement classroom, brightened by the red of the girls’ head scarves and the walls emblazoned with Quranic verses written in Arabic script.

Semra had spent years working overtime at her cleaning job, saving enough to pay for extra courses that she hoped would secure a place for her daughter at an academically rigorous secular school. But after taking the admissions test under Turkey’s system for allocating slots in public schools, her daughter was one of nearly 40,000 students automatically assigned to the state-run religious schools.

“It felt like someone had tossed a bucket of boiling water over my head,” Semra said, giving only her first name out of fear that her daughter would be reprimanded at school.

Education has become the latest front in Turkey’s cultural wars, pitting the country’s tradition of secularism against the religious mores of President Recep Tayyip Erdogan and his Islamist allies. The tensions underscore the way Mr. Erdogan’s Justice and Development Party has gradually injected religion into public life over the past 12 years in an effort to reshape Turkish society.