Like the protesters — who gathered for the second large anti-government demonstration in two weeks — Turkey's powerful secular military has accused Prime Minister Recep Tayyip Erdogan of tolerating radical Islamic circles.
"They want to drag Turkey to the dark ages," said 63-year-old Ahmet Yurdakul, a retired government employee who attended the protest.
More than 300,000 people took part in a similar rally in Ankara two weeks ago. Police, who said Sunday's demonstrators numbered around 700,000, cordoned off the area and conducted body searches at several entry points.
Sunday's demonstration was organized more than a week ago, but it came a day after Erdogan's government rejected the military's warning about the disputed presidential election and called it interference that is unacceptable in a democracy.
The ruling party candidate, Foreign Minister Abdullah Gul, failed to win a first-round victory Friday in a parliamentary presidential vote marked by tensions between secularists and the pro-Islamic government. Most opposition legislators boycotted the vote and challenged its validity in the Constitutional Court.
The military said Friday night that it was gravely concerned and indicated it was willing to become more openly involved in the process — a statement some interpreted as an ultimatum to the government to rein in officials who promote Islamic initiatives.
Sunday's crowd chanted that the presidential palace was "closed to imams."
Some said Parliament Speaker Bulent Arinc was an enemy of the secular system, because he said the next president should be "pious."
In the 1920s, with the Ottoman Empire in ruins, Mustafa Kemal Ataturk imposed Western laws, replaced Arabic script with the Latin alphabet, banned Islamic dress and granted women the right to vote.
The ruling party, however, has supported religious schools and tried to lift the ban on Islamic head scarves in public offices and schools. Secularists are also uncomfortable with the idea of Gul's wife, Hayrunisa, being in the presidential palace because she wears the traditional Muslim head scarf.
"We don't want a covered woman in Ataturk's presidential palace," said Ayse Bari, a 67-year-old housewife. "We want civilized, modern people there."
The military, one of the most respected institutions in Turkey, regards itself as the guardian of the secular system and has staged three coups since 1960.
"Neither Sharia, nor coup but fully democratic Turkey," read a banner carried by a demonstrator on Sunday.
By Benjamin Harvey, Associated Press; the AP's Selcan Hacaoglu in Ankara contributed to this report.