Following a failed coup against Turkish President Recep Tayyip Erdogan, the government moved swiftly to shore up his power and remove those perceived as an enemy, saying Sunday it has detained 6,000 people.
The crackdown targeted not only generals and soldiers, but a wide swath of the judiciary that has sometimes blocked Erdogan, raising concerns that the effort to oust him will push Turkey even further into authoritarian rule.
Friday night's sudden uprising by a faction of the military appeared to take the government — and much of the world — by surprise.
The plotters sent warplanes firing on key government installations and tanks rolling into major cities, but it ended hours later when loyal government forces regained control of the military, and civilians took to the streets in support of Erdogan. At least 294 people were killed and more than 1,400 wounded, the government said.
On Sunday, Prime Minister Binali Yildirim said the coup had failed and life has returned to normal.
"Another calamity has been thwarted," Yildirim said in Ankara after visiting state TRT television, which had been seized by soldiers supporting the coup. "However, our duty is not over. We shall rapidly conduct the cleansing operation so that they cannot again show the audacity of coming against the will of the people."
Yildirim said those involved with the failed coup "will receive every punishment they deserve." Erdogan suggested that Turkey might reinstate capital punishment, which was legally abolished in 2004 as part of the country's bid to join the European Union.
Speaking to a large crowd of his supporters in front of his Istanbul residence Sunday evening, Erdogan responded to frequent calls of "We want the death penalty!" by saying: "We hear your request. In a democracy, whatever the people want they will get."
Funerals were held for some of those who were killed in the coup attempt, including Erdogan's campaign manager Erol Olcak and his 16-year-old son, Abdullah Tayyip Olcak. The president, who attended the service, wept and vowed to take the country forward in "unity and solidarity."
The government's announcement that 6,000 people had been detained — including three top generals and hundreds of soldiers — suggested a wide conspiracy. Observers said the scale of the crackdown, especially against the judiciary, indicated the government was taking the opportunity to further consolidate Erdogan's power.
"The factions within the military opposed to Erdogan who did this just gave him carte blanche to crack down not only on the military but on the judiciary," said Aykan Erdemir, a former lawmaker from the main opposition party and now a senior fellow at the U.S.-based Foundation for Defense of Democracies. "The coup plotters couldn't have helped Erdogan more."
Even before the chaos in Turkey, the NATO member and key Western ally in the fight against the Islamic State group had been wracked by political turmoil that critics blamed on Erdogan's increasingly heavy-handed rule. He has shaken up the government, cracked down on dissent, restricted the media and renewed fighting with Kurdish rebels.
The rapid suppression of the putsch was greeted by Turks across the political spectrum with opposition parties joining quickly to condemn it. In a half-dozen cities, tens of thousands marched throughout the day after officials urged them to defend democracy and back Erdogan, Turkey's top politician for 13 years.
At nightfall, flag-waving crowds rallied in Istanbul's Taksim Square, Ankara's Kizilay Square and elsewhere.
The Yeni Safak newspaper used the headline "Traitors of the country," while the Hurriyet newspaper declared "Democracy's victory."
"Just a small group from Turkish armed forces stood up against our government ... but we, the Turkish nation, stand together and repulse it back," said Gozde Kurt, a 16-year-old student at a morning rally in Istanbul.
The failed coup and the subsequent crackdown followed moves by Erdogan to reshape both the military and the judiciary. He had indicated a shakeup of the military was imminent and had also taken steps to increase his influence over the judiciary.
This month, parliament approved a controversial bill to reform two Turkish high courts, which allows the government to dismiss hundreds of administrative and high appeals court judges and allow Erdogan to replace them with judges loyal to him. Parliament passed the bill even as authorities were grappling with a deadly triple suicide bomb attacks at Istanbul's Ataturk Airport.
The opposition had appealed the legislation to the high court unsuccessfully, but Erdogan has not yet signed it in to law. Two Constitutional Court justices were among the thousands of members of the judiciary it had detained Saturday.
It is not clear what effect the post-coup purge will have on the judiciary, how the government will move to replace the dismissed judges and prosecutors, or where the trials for those detained would be held.
The government alleges that the coup conspirators were loyal to moderate U.S.-based cleric Fethullah Gulen, whom Erdogan has often accused of trying to overthrow the government.
Gulen, who lives in Saylorsburgh, Pennsylvania, espouses a philosophy that blends a mystical form of Islam with democracy. He is a former Erdogan ally turned bitter foe who has been put on trial in absentia in Turkey, where the government has labeled his movement a terrorist organization. He strongly denies the government's charges.
In recent years, the government had already moved to purge the police and judiciary of Gulen followers. The military, founded on secularist ideals, has been a staunch opponent of Gulen, and so far officials have not offered evidence that he was involved in the coup attempt.
Speaking at a funeral in Istanbul, Erdogan vowed to "clean all state institutions of the virus" of Gulen's supporters. He also called on Washington to extradite Gulen.
At two weekend news conferences, Gulen strongly denied any role in or knowledge of the coup.
"As someone who suffered under multiple military coups during the past five decades, it is especially insulting to be accused of having any link to such an attempt," he said.
He said he did not fear extradition.
"This doesn't worry me at all. But I'm not going to do anything that will harm my dignity or that will go against my dignity," he said.
U.S. Secretary of State John Kerry said the United States would entertain an extradition request for Gulen, but Turkey would have to present "legitimate evidence that withstands scrutiny."
Ziya Meral of the Centre for Historial Analysis and Conflict Research, a civilian think tank affiliated with the British Defense Ministry, said the motives of the plotters remain unclear, but the allegations against Gulen were dubious.
"I am more inclined toward a network within the armed services who were disturbed about where Turkey is heading," she said.
The allegations will only add to the pressure on the U.S. government and signal new uncertainty in U.S.-Turkish relations.
The putsch attempt led to a temporary halt to air operations by the U.S.-led coalition against the Islamic State group in neighboring Syria and Iraq from Turkey's Incerlik air base, but the Pentagon said Sunday that Turkey has reopened its airspace.
A Turkish government official said that the commander of the base, Gen. Bekir Ercan Van, was among those detained.
The state-run Anadolu Agency also said authorities have issued a warrant for the arrest of Erdogan's top military aide, Col. Ali Yazici, although it wasn't clear what role he may have played in the attempted coup.
The agency said 70 generals and admirals, including former Gen. Akin Ozturk, an air Force commander, were detained in the investigation. Of the generals and admirals brought before court, 11 were put under arrest as of Sunday night and the rest are awaiting processing.
Security forces arrested a group of coup plotters who had been holding out at one of Istanbul's airports Sunday, a Turkish official said. In addition, Anadolu reported that seven people, including a colonel, were detained at an air base in the central Anatolian city of Konya.
Gen. Umit Dunda said at least 104 conspirators were among those killed, describing them as mainly officers from the air force, the military police and armored units.
Security forces rounded up 52 more military officers for alleged links to the coup. Anadolu said a detention order has been issued for 110 judges and prosecutors in Istanbul alone for alleged involvement with the group responsible for the coup.
The suspects are being charged with "membership in an armed terrorist organization" and "attempting to overthrow the government of the Turkish Republic using force and violence or attempting to completely or partially hinder its function." The agency said 58 homes of prosecutors and judges have been searched.
Officials also said 2,745 judges and prosecutors have been dismissed.
Another 149 police were detained in Ankara, according to Anadolu, citing the office of the city's governor.
Fraser reported from Ankara. Dominique Soguel, Emrah Gurel, Bram Janssen and Cinar Kiper in Istanbul and Mucahit Ceylan in Ankara, Desmond Butler in Washington and Michael Rubinkam in Saylorsburg, Pennsylvania also contributed.