On the night of the failed military coup, Istanbul’s towering bridges hosted hellish scenes of chaos and bloodshed, as ordinary Turks — in stunning acts of bravery and defiance — poured into the streets to halt a violent army takeover of the country’s civilian government.

But by dawn, the once-menacing soldiers who had seized key roads and infrastructure just hours before, could be seen surrendering to police on those same bridges, their hands in the air as they stood in the early-morning light. More masses of triumphant citizens, gleeful that the government had prevailed, came out to gawk at stalled armored vehicles and take selfies with the police who had put down the unpopular putsch.

The police officers, for their part, basked in the glory as city residents treated them like heroes. In the crowded Istanbul district of Uskudar, a young boy with a Turkish flag posed for a photograph with riot police in front of an armored vehicle seized in the counter-coup.

“Turkey is in secure hands now,” one of the police officers said, although he was not authorized to speak to the news media.

What we know about the failed coup attempt in Turkey

Men streamed through the city’s squares waving oversize Turkish flags — red, with the white star and crescent associated with Islam — and chanting support for the government.

“I was out on the streets until 6 a.m. I was out with all of my family — there were 20, maybe 30 of us,” said Olgun Gunes, a 41-year-old Uskudar resident and textile worker. “There was a war beginning last night, but we went to the streets and took responsibility for our country.”

In Istanbul and in Ankara — the Turkish capital, which saw the heaviest fighting between pro- and anti-coup ­forces — life slowly began to return to normal Saturday. Shops near Istanbul’s famed Taksim Square reopened, and street vendors reappeared selling roasted corn and wreaths of flowers. Cooks at local cafes fired up greasy Turkish kebab, and residents flocked to street-side cafes to drink hot tea in the afternoon sun.

But things felt different, many residents said.

Local muezzins, those appointed to perform the Muslim call to prayer, led sermons from the early morning and into the evening, on orders of the Religious Affairs Directorate. On televisions, which were switched on everywhere, there was news of arrests of coup plotters, purges of judges and a tense standoff at a military headquarters in Ankara, where soldiers were holed up.

Flights to and from Istanbul’s Ataturk Airport resumed, were suspended and then resumed again, causing travel chaos at one of the world’s busiest international hubs. Ankara’s airport remained closed, reports said.

In Istanbul, even opponents of President Recep Tayyip Erdogan, who at one point on Friday night addressed the nation via a smartphone video chat, said they did not want to see him shoved aside in a coup. It would set back the country for years, they said.

In the up-and-coming Besiktas neighborhood, shops that residents had flooded the night before in a last-minute bid to stock up on key supplies were also being reopened. But only a few people were out on the streets.

Sedat Demircan, 57, retired from foreign trade business, was out looking for fresh bread.

“I want Recep Tayyip Erdogan to go, but not like this,” he said.

Hakan Sengezen was at his shop, where he sells purses, luggage and backpacks. He said the streets were filled with rumors about who was behind the coup. Sengezen said he wasn’t sure what to think.

“I do not want a coup,” he said. “Every time there is a coup the country goes back 10 or 20 years, in terms of the economy, in terms of security. I don’t want the military to rule. They interfere with everything. They institute curfews; they interfere with how people dress.”

Gizem Oktay, 23, was at a party with friends in the Taksim district when news of the coup broke and everyone rushed home. Her father is an officer in the Turkish army.

“When I got back to the barracks, the soldiers were waiting at the ready at the entrance. They rushed us in,” she said. “It was fairly calm here, but in the morning the police came and are not allowing any entry or exit.”

On Saturday evening, several thousand people rallied in Taksim Square to celebrate the failure of the attempted coup. Young men and women waved Turkish flags, and many others wore them as capes as they sang, danced and chanted both nationalist and Islamic slogans.

Police vehicles with water cannons stood at the entrance to the square. Young men — some with selfie sticks — scaled the square’s monument, where revelers had stuck a Turkish flag in the hand of the statue of Mustafa Kemal Ataturk, founder of the modern Turkish republic.

“God is great! God is great! God is great!” yelled a group of bearded men in white robes and sandals — clothing typically worn by the religiously conservative. Standing near them were women in tight jeans who clapped their hands, whistled and chanted, “Turkey! Turkey!”

The crowds were diverse and included people who most likely are divided when it comes to Turkey’s combustible domestic politics. Some of the revelers struck a more somber tone and prayed amid the celebrations. Others crowded into cars on nearby streets, honking their horns and blaring music by popular American rappers such as Pitbull.

One man, who identified himself as Russell but declined to give his last name, said he came to the bustling downtown shopping district to demonstrate support for Turkish democracy. “This is about keeping our country away from military rulers. The people should be running Turkey,” the 29-year-old marketing executive from Istanbul said. “This is not about Erdogan.”

He was referring to Erdogan’s call to Turks to take to the streets in a show of support.

The Turkish leader nevertheless appeared to have a large number of supporters at the rally in Taksim, as well as at another celebration at Istanbul’s main international airport. “Erdogan! Erdogan!” yelled a group of veiled women who walked between cars stuck in a mile-long traffic jam near the airport.

Booth reported from Jerusalem. Hugh Naylor in Istanbul contributed to this report.