Mr. Erdogan has been lionized for serving jail time for reciting a poem with religious overtones in public while he was Istanbul’s mayor. And in an interview last year with The Istanbul Review, a literary journal, he said: “Censorship is an unacceptable method of obstruction, not only in literature but in all arts, media, politics and many other fields. The freedom of expression is a right that we work to solidify every day and a subject we are particularly sensitive about.”

But in the years since he became prime minister, his government has become a leading jailer of journalists and opposition writers. And over the weekend, he was particularly vocal about protesters’ use of social media, singling out Twitter as a “menace” used to disseminate lies.

Mr. Erdogan, 59, grew up in a pious, low-income neighborhood in Istanbul when Turkey was ruled by an elite that heavy-handedly banished religious expression from public life. In rising to power, he took that once-peripheral social class to the center of Turkish public life. And analysts say it will be that constituency’s reaction that determines how he weathers the current crisis.

For now, it seems to be standing solidly behind him.

Kasimpasa, the hilltop neighborhood where Mr. Erdogan grew up, is not far from Taksim Square, the epicenter of the protests. There, residents refer to Mr. Erdogan as “Baba,” or father, in Turkish, and recall Fridays, after prayers, when neighborhood children would follow him into the shop across from his apartment building and he would buy them candy. He visited the neighborhood last week to open a new sports center where children can learn archery, another offering to the supporters who propelled him to power.

At the shop across from Mr. Erdogan’s apartment, Semiha Pacal, the owner, said, “The second he comes, people swarm him.”