Customers check their Turkish lira bank notes after visiting a currency-exchange bureau in Istanbul on July 19. (Ismail Ferdous/Bloomberg News)

Yildiz Gerjain feels cornered.

That sensation has intensified since a coup attempt last week that she did not support, a subsequent purge launched by a strongman president she opposes and large rallies by conservative Islamists whom she fears.

The tumult is rattling Turkey, which was founded in secularism but has become profoundly divided over the role of Islam in society. And when the dust settles, it is unclear whether the nation’s shaky democracy will be left standing after such turbulence.

Gerjain and many other Turks who desire stronger democratic institutions, rights for women and gays and a country with no dictators, whether military or Islamist, don’t seem optimistic.

“What can we do in this situation? It’s frightening from every side,” Gerjain said as she walked through Istanbul’s upscale Nisantasi neighborhood Tuesday morning.

In a tank top and capri pants, the 34-year-old architect expressed bewilderment over the chaotic situation in her country since Friday evening.

That was when rebel soldiers launched their attempt to overthrow President Recep Tayyip Erdogan’s government. They bombed parliament, blocked bridges in Istanbul with tanks and took over state media. At least 232 people died in the resulting chaos as thousands of police and other people loyal to Erdogan intervened.

The coup bid did not succeed, which Gerjain said was a relief. The country has a painful history of military takeovers.

“I remember growing up and my parents telling me how the coups were so bad, how so many innocent people were jailed and killed,” she said. “We have come so far since then, and a coup here would set us back.”

But since Friday, authorities have responded ferociously by sacking or arresting an extraordinary number of people — tens of thousands and counting — from the military, the police, the judiciary and other institutions. Many, if not most, Turks opposed the attempted putsch. Many also fear that the sweeping purge it triggered will enable the Erdogan, an Islamist, to further weaken rivals and chip away at the country’s secular traditions.

“The polarization of Turkish society is still there, if not more so, even though really no one supported this coup attempt,” said Bulent Aliriza, director of the Center for Strategic and International Studies’ Turkey Project.

Over the years, Erdogan has closed down media outlets, silenced critics and sidelined challengers. Secular-leaning citizens have been alarmed by his introduction of religious education in schools and greater restrictions on alcohol.

Opposition parties appear too weak to stop him, and so, too, did nationwide protests calling for curbs to his powers that started in Istanbul’s Gezi Park three years ago.

It was all supposed to be different when Erdogan came to power in 2002. Then, many saw him as a gentle Islamist and reformer who would tame the military and usher in a new era of democratic rule. Fast-forward 14 years, and he now wants to replace the country’s parliamentary democracy with an executive presidency that would make him perhaps the most powerful figure here since Mustafa Kemal Ataturk, Turkey’s founding father.

That prospect terrifies Mesut Duman, 22, who reveres Ataturk, isn’t religious and sees Turkey as part of Europe rather than the Middle East.

Standing on a sidewalk with hands buried in his pants pockets, the salesman at the Marks & Spencer department store in Nisantasi recalled his initial reaction to the attempted coup. Around him were women in tight pants striding in high heels and holding shopping bags from stores such as Gucci and Versace.

He recalled seeing images on Facebook of soldiers commandeering bridges and how he immediately thought to himself, “Erdogan is going to take advantage of all of this,” he said.

As it was all unfolding, the Turkish leader appeared to do just that. He turned to his base of religious supporters, using mosques across the country to call on the faithful to flood the streets to block the mutinous soldiers. In remarks shortly after the attempted putsch, Erdogan described the incident as “a gift from God.”

Islamists turned out in especially large numbers at rallies and public squares. In a surprise to many Turks, even militant Islamists have participated in the anti-coup rallies, said Soner Cagaptay, a Turkey expert at the Washington Institute for Near East Policy. These fundamentalists have been linked to subsequent attacks on soldiers and minority religious groups, he said.

“There’s a sense of shock and intimidation by the scale of Islamist fervor in the streets because of all this,” he said. “A few years ago, you would never have seen these jihadi types out in public like they have been in recent days.”

The fundamentalists are linked to the blowback from Turkey’s policy of aiding hard-core Islamist fighters in the civil war in Syria who, in turn, have increasingly proselytized and recruited from inside Turkey, Cagaptay said.

Over the past year, a string of suicide bombings linked to the Islamic State militant group have rocked Turkey, killing hundreds and badly damaging the economy.

Levent Piskin, 27, a gay rights activist in Istanbul, has observed the fundamentalists in streets and public gathering places, including the downtown Taksim Square. On Monday, he said, a group of them harassed a friend who was walking near the square, because of her tight-fitting clothes.

The coup may have given the fundamentalists more freedoms to impose their beliefs, he said.

“I’m gay. I support freedom of speech and democracy. So of course I’m afraid of these Islamists,” he said. “The whole situation is worrying.”