When the army cut off traffic in Istanbul on Friday night by shutting two bridges in the opening moments of a coup, the municipality ordered ferries to work overtime. City trucks blocked roads near army barracks. Buses and subways operated free of charge, and local officials and mosque preachers helped mobilize government supporters to the streets.
And when President Recep Tayyip Erdogan finally emerged in public, after uncertain hours in which he narrowly missed being seized at a seaside hotel by soldiers trying to topple his government, he flew, not to the capital, Ankara, but to Istanbul, where he remained throughout the weekend and on Monday.
Ankara may be the seat of Turkey’s government, but it was Mr. Erdogan’s grip on Istanbul, a city he once governed as mayor, that was crucial in putting down the coup.
In the failed coup’s aftermath, it was in the streets, mosques and public squares in Istanbul that his Islamist supporters raucously celebrated, and where Mr. Erdogan consolidated his hold on power.
The two cities, in many ways, represent Turkey’s deep divisions: Istanbul owns the hearts of the Islamists and is Turkey’s showcase to the world, while Ankara is a special place for secular Turks.
“Istanbul’s becoming almost the second capital of the country has been very instrumental in preventing the coup,” said Yusuf Muftuoglu, who was an adviser to the former president, Abdullah Gul, and briefly for Mr. Erdogan.
The drama of the failed coup mostly played out across two urban spaces and the skies overhead — Istanbul, the sprawling megacity that symbolizes the country’s past as the seat of Islamic empire, and Ankara, the utilitarian capital, a onetime Anatolian backwater built up by modern Turkey’s secular founder, Mustafa Kemal Ataturk.
Much of the violence occurred in Ankara, where different factions of the armed forces battled over government buildings. But the events in Istanbul proved crucial in fending off the coup. It was there that two private news channels broadcast anti-coup coverage and gave a platform to elected leaders, including Mr. Erdogan.
During his time in power, Mr. Erdogan has spent far more time in Istanbul than previous presidents and has overseen the construction of Turkey’s largest mosque in the city.
He has also built up the police force, much of which is based in Istanbul. By stocking the force with loyalists and purging suspected enemies, he created a counterweight to the military, which has a history of carrying out coups against civilian governments.
And it was largely the police special forces that defended the government over the weekend, confronting the renegade military factions.
In the days before the attempted coup, a palpable sense of melancholy could be felt when walking through the city, whose singularity is measured in numbers: seven hills, two continents, the capital of three former empires.
Turks call it “huzun,” a rich, Arabic-rooted word that means melancholy and a lot more: loss, sadness, spiritual anguish. Turkey’s most famous novelist, Orhan Pamuk, used it to describe Istanbul in the dreary years after the fall of the Ottoman Empire.
The word is back in the city’s lexicon now, as years of optimism about Turkey’s growing power on the world stage give way to anxiety over terrorism and internal conflicts.
After the coup was decisively put down, and Mr. Erdogan’s supporters flooded the streets and city squares over the weekend to celebrate, a sense of buoyancy returned to the streets, but the joy masked a deep unease that has enveloped the city.
Istanbul, where ancient mosques and churches jostle with gleaming skyscrapers and faux-Ottoman shopping malls to define an evolving cityscape, was reshaped by Mr. Erdogan’s Islamist government, which created a glistening image of the city that is now threatened by instability.
The government embraced Turkey’s Ottoman and Islamic past as a mythical time of harmony and reimagined Istanbul as Turkey’s true capital, investing heavily in public works projects, new shopping malls and office buildings. Ankara took a back seat.
“I think the city was presented as this perfect dream without its problems,” said Kaya Genc, a novelist and essayist who wrote about “huzun” after the recent attack on Istanbul’s main airport, which left dozens of people dead. “Maybe it was a lie, but we miss it.”
Now, he said, “is the return of the real Istanbul.”
By that he meant a city whose mood is more in sync with its unstable past of military coups, political violence and economic crisis. In recent years, the government built an image of Istanbul as an urban wonderland of fascinating history and great architecture and cuisine, and tourism boomed.
Mr. Genc said that like many other liberals and intellectuals he bought in to the vision. “A past was reinvented, and repackaged as this great, multicultural history where there are no conflicts,” he said.
Even before the failed military coup, all that was clouded by spillover from the Syrian civil war — terrorism and a flood of refugees, hundreds of thousands in Istanbul alone — that set the city on edge.
“Everything is being Arabized,” said Karaca Borar, who owns an antiques shop on one of the crooked, cobbled streets in European Istanbul, and supplied many of the items that fill a nearby museum owned by Mr. Pamuk that is based on his novel “Museum of Innocence.”
He said he was tired of hearing the Arabic greeting of “salaam aleikum” on the streets, and tired of so many Syrians in general. (It is a widely shared sentiment: When Mr. Erdogan recently said Turkey should offer citizenship to Syrians, a right-wing secular newspaper called Syrians “vermin” in a front-page headline.)
Asked about the mood of the city, which before the coup attempt had faced several devastating terrorist attacks for which the Islamic State was blamed, Mr. Borar said, “Terrible, terrible, terrible.”
“We’re not happy,” he said. “I’m not at ease.”
He continued: “We were the only secular, decent country in a bad region. Now, we are like one of those Arab states.”
With so many threats, even the weather can set off panic, a clap of thunder sending people scampering for cover. People walking the streets are scrutinized for what they are wearing and what they are carrying. A backpack could be a bomb. A sweater or jacket in summertime could conceal a vest of explosives.
Nowadays, it seems, all of Turkey’s old conflicts — most prominently the divide between religious and secular Turks — and many new ones, are coming to the fore.
The most dramatic was the long night of uncertainty as fighter jets buzzed the sky, gunfire echoed across the city, and protesters mobilized as the military tried to secure the city.
But even before that, Turkey’s traumas were playing out across Istanbul, in bitter conversations about politics, in painful decisions to move away or in to gated communities, in smatterings of protests quickly put down by the police, and in new debates over the use of public spaces.
Three years ago, protesters in Gezi Park, in Taksim Square in European Istanbul where Mr. Erdogan’s supporters rallied over the weekend, rose up to oppose plans to convert the park into a shopping mall.
The protests became a widespread challenge to his rule, which is growing increasingly autocratic. It produced no lasting political changes, but it did save the park.
But maybe not for long. In recent comments that seemed designed to provoke his enemies, Mr. Erdogan said he could revive the plan.
On a recent afternoon, Ali Erdogan, a retired military man in his late 60s who is not related to the president, sat on a bench in Gezi Park, where the city has planted new trees, blossoming with pink flowers, and told how his life had improved since Mr. Erdogan came to power more than a decade ago.
He pulled out his card for retirees for free rides on Istanbul’s subway, which has been modernized in recent years, as has Turkey’s health care system. “Everything is new and shiny,” he said.
More important, he said, he can freely express his religion, something he was unable to do when Turkey’s secular elite ruled the country for decades.
He said when he was in the military, the guardian of secularism, he had to conceal his religiosity. “I had to lie that I prayed five times a day,” he said. “I had to find a secret corner to pray.”
The city’s most conservative district is Fatih, in the old city, across the Golden Horn waterway that divides European Istanbul.
There, Mr. Erdogan spoke at a funeral on Sunday, and rallied his supporters to keep gathering in the city’s public squares. It is also where three suicide attackers who carried out the airport bombings lived in an orange apartment building.
But the area is far from homogeneous. In one gentrifying enclave of Fatih, in a neighborhood called Balat, shabby-chic cafes and quirky antique shops have sprouted on the narrow streets, raising tensions and testing the limits of social diversity.
“Istanbul used to be like a village,” said Hikmet Bardok, 63, a longtime resident. “I don’t recognize it anymore. A lot of people who live here are poor. And these rich people are coming in an looking for places to park their Ferrari.”
Mr. Bardok said he quit drinking in 1994 when he turned to religion, and blamed secular Turks for the country’s polarization because they are “arrogant and disrespectful.”
Now that they are moving in to his neighborhood, he is worried that “in five to 10 years this place is going to turn into Amsterdam.”
Mr. Genc, meanwhile, has been thinking of writing a book on what he calls the “New Istanbul,” a chronicle of the “artificial, distant new neighborhoods” that have built up in the city’s outer reaches during Mr. Erdogan’s tenure.
Mr. Erdogan once enjoyed the support of many of Istanbul’s intellectuals and elites, some of whom now call him a dictator, even though they opposed a coup. They once thought him capable of healing the country’s divides, and basked in the optimism that flowed through Istanbul.
Now, in the aftermath of the coup attempt, they are left to wonder if Mr. Erdogan will turn more autocratic or, perhaps, seize the time to patch up relations with segments of the society he has alienated.
That will become clearer in the days and weeks ahead. For now, Turks are simply trying to make sense of their dizzying weekend.
The morning after the coup attempt, Mr. Genc woke early, and went for a walk along the Bosporus. “In the background was the waterway,” he wrote in an essay for The New York Times, “a burning sun and two bridges that span two continents, where just hours before tanks had been firing shots.”