Turkey’s government defeated a coup attempt by a renegade faction of the military that pummeled government and security institutions overnight with fighter jets, reasserting control Saturday after hours of chaos and clashes that killed at least 265 people and plunged the already troubled country into further uncertainty.

More than 100 coup plotters are now dead, acting military chief Gen. Umit Dundar said on live TV, while another 161 people – including civilians and police – were killed as ordinary Turks poured into the streets to confront tanks amid pitched battles in urban areas. At least 1,440 were wounded, officials said:-

“The situation is completely under control,” Prime Minister Benali Yildirim announced early Saturday afternoon, adding that more than 2,800 Turkish members of the military have been arrested and calling the attempt “a dark stain for Turkish democracy.”

The move by rogue officers and their supporters was the most significant challenge to the country’s stability in decades, and it raised fears that a close U.S. ally could be destined for a prolonged period of civil strife.

More than 1,500 military personnel were arrested across Turkey on Saturday.

In Istanbul, by early afternoon the bridges were reopened and traffic began to move again on the streets after a night of gunfire, explosions and violent confrontations on the bridges and in the city’s main squares.

Small groups of residents gathered on corners and debated in hushed tones, and shelves in many local shops were completely empty after a late-night rush to stock up on food and water.

The U.S. Embassy warned citizens against heading to the airport amid reports of ongoing sporadic gunfire.

The night before, scores of Turkish citizens had flooded the streets of Istanbul and Ankara to confront the tanks rumbling into their cities.

Gruesome videos posted on social media showed tanks crushing protesters who tried to block their path, bloodied bodies strewn on the streets of Ankara and helicopters firing into civilian crowds.

Just after dawn and hours of overnight clashes, Turkish President Recep Tayyip Erdogan appeared at the Istanbul airport and greeted a huge crowd of flag-waving supporters.

He had been vacationing on the Aegean Sea when the military intervention launched Friday night. In a statement distributed by the armed forces, the rebel military faction said they had “seized complete control of the government” to “restore rights and freedoms” and establish the rule of law.

But Erdogan, who critics say had grown increasingly authoritarian, remained defiant – even as rebel gunners fired on the parliament and presidential palace in Ankara, and war planes swooped over central Istanbul.

“This government, brought to power by the people, is in charge,” he said from the Istanbul airport. “A minority group within the armed forces targeted the integrity of our country.”

But with reports that gunfire and explosions were still being heard on the streets of Istanbul and Ankara well into the morning, it was far from clear whether the worst crisis in Turkey in decades had been resolved.

The splits within the security forces and the chaotic scenes on the streets revealed a society polarized between supporters and opponents of the deeply controversial Erdogan, whose autocratic behavior has alienated some segments of Turkish society.

Ultimately, though, Erdogan remains hugely popular among his core constituents, and with opposition parties as well as important branches of the military and security services rallying to the government’s side, it did not appear as though the renegades had the support in society they thought.

Dundar was appointed acting military chief overnight, and on Saturday said that Turkey had “displayed a historic cooperation between the government and the people.”

“The nation will never forget this betrayal,” he said.

The upheaval began Friday evening when tanks and other armored vehicles appeared on bridges across the Bosporous in Istanbul and F-16 fighter jets began streaking through the skies.

Shortly afterward, an anchor with the state television broadcast read a statement purportedly from the Turkish military saying it had taken control of the country, citing concerns about the increasingly autocratic behavior of Erdogan and his ruling Justice and Development Party.

“The Turkish Armed Forces, in accordance with the constitution, have seized management of the country to reinstate democracy, human rights, and freedom, and to ensure public order, which has deteriorated,” the statement said.

President Recep Tayyip Erdogan said his government was now fully in control.

Many thousands responded, with protesters gathering in venues including Istanbul’s central Taksim Square and outside Erdogan’s palace in Ankara. Mobile phone videos uploaded to social media sites showed scenes in which people scrambled over tanks to try to block their path and soldiers opening fire on some of the crowds.

Dundar blamed the coup attempt on a small group of disgruntled military officers loyal to the movement of a U.S.-based cleric, Fethullah Gulen, who maintains a network of adherents across Turkey and has long challenged Erdogan’s hold on power.

He said the military would purge members of the movement from its ranks, adding that the “era of coups and juntas have come to a close.”

The officers were destined to lose their jobs in August during a military reshuffle, a Turkish official added.

Turkish authorities on Saturday removed 2,745 judges from duty following the coup attempt, broadcaster NTV reported, citing a decision by the High Council of Judges and Prosecutors. The judges were removed because of suspicions that they have links to Gulen.

Secretary of State John F. Kerry said Saturday that Turkey has not asked for the extradition of Gulen, who lives in exile in rural Pennsylvania, but he said the United States would consider such a request.

During a stop in Luxembourg, Kerry said the United States would support investigations to determine who instigated Friday’s attempted coup and from where its support originates. He said he anticipates questions will be raised about Gulen.

“Obviously we invite the government of Turkey, as we always do, to present us with any legitimate evidence that withstands scrutiny,” Kerry said.

Kerry also criticized the coup, saying elections are the proper way to settle disputes in a democracy.

“I must say,” he added, “it does not appear to have been a very brilliantly planned or executed event. But let’s reserve judgment until all the facts are in.”

The Gulenist movement in Turkey denied involvement, however, and amid the confusion, it was impossible to confirm who was behind the attempt to topple the government.

Erdogan has made many enemies in the 13 years he has run Turkey, first as prime minister and then, since 2014, as president, including within the military. Hundreds of officers have been imprisoned by his government, some of them accused of coup-plotting, and it had been widely thought that his crackdown on dissent had dispelled the risk of uprisings in the once coup-prone country