ISTANBUL — They ostensibly rallied here on Sunday to protest the attempted overthrow of their government. But what seemed to worry them was the direction of that same government and a crackdown led by its powerful leader, President Recep Tayyip Erdogan.

“I’m afraid. Erdogan is trying to become a dictator,” said Ahmet, a 21-year-old university student who joined thousands of other demonstrators here in Istanbul’s Taksim Square.

He declined to give his last name because, like many in Turkey, he feared being swept up in the extraordinary purge of state institutions triggered by a failed coup on July 15.

The measures have involved the detention, suspension and firing of tens of thousands of people, including soldiers, police, judges and civil servants. On Saturday, Turkey’s presidency ordered the closure of 1,043 schools, 1,229 charities and foundations, 15 universities and 35 medical institutions.

Participants at the rally waved Turkish flags and chanted nationalist slogans. Some drank beer – an unspoken rebuke to the Islamic orientation of Erdogan’s government – and held up posters showing the visage of Turkey’s secular founding father, Mustafa Kemal Ataturk.

They were united in expressing concern about the turbulence shaking this Middle East nation of 75 million people. Many also seemed careful not criticize their president – at least not in public or in front of foreign journalists.

A climate of fear has gripped many Turks, who say the government’s response seems more about Erdogan consolidating his power than just rooting out coup plotters. Turkey’s allies, including the United States, have expressed similar concerns.

Supporters of the Republican People’s Party – the country’s main opposition, referred to here as the CHP – have long been critical of the Turkish leader’s religious agenda and attempts to silence journalists and critics.

Even so, the CHP’s secular-leaning leadership tried to extend an olive branch to Erdogan and his Islamist allies. The party organized Sunday’s rally, and its officials formally extended an invitation to Erdogan’s Justice and Development Party and its supporters.

That gesture felt at odds with comments on Friday by the CHP’s head, Kemal Kilicdaroglu. He suggested that Erdogan had taken the purge too far.

“We want all those who are prosecuted on coup-related charges to be tried in line with democracy and the rule of law. We don’t want a witch hunt,” Kilicdaroglu told NTV, a private broadcaster.