ANKARA, Turkey -- Forces loyal to Turkey's president quashed a coup attempt in a night of explosions, air battles and gunfire that left more than 250 dead Saturday. Authorities arrested thousands of people as President Recep Tayyip Erdogan vowed those responsible "will pay a heavy price for their treason."
The chaos capped a period of political turmoil in Turkey - a NATO member and key Western ally in the fight against the Islamic State of Iraq and Syria, or ISIS - that critics blame on Erdogan's increasingly authoritarian rule. He has shaken up the government, cracked down on dissidents, restricted the news media and renewed conflict with the Kurdish minority.
Pressure has also come from millions of refugees who have fled violence in neighboring Syria and Iraq, and a series of bloody attacks blamed on ISIS and Kurdish rebels.
Erdogan was on a seaside vacation when tanks rolled into the streets of Ankara and Istanbul. He flew home early Saturday and declared the coup to have failed.
The uprising appears not to have been backed by the most senior ranks of the military, and Turkey's main opposition parties quickly condemned the attempted overthrow of the government. Gen. Umit Dundar, newly appointed as acting chief of the general staff, said the plotters were mainly officers from the Air Force, the military police and the armored units.
The unrest claimed at least 265 lives, according to a tally compiled from official statements. Prime Minister Benali Yildirim said 161 people were killed and 1,440 wounded in the overnight violence. He said 2,839 plotters were detained.
Dundar said at least 104 "coup plotters" had died.
Yildirim described the night as "a black mark on Turkish democracy" and said the perpetrators "will receive every punishment they deserve."
Turkey's NATO allies lined up to condemn the coup. In Washington, President Obama urged all sides to support Turkey's democratically elected government. NATO Secretary-General Jens Stoltenberg said he spoke to Turkish Foreign Minister Mevlut Cavusoglu and called for respect for democracy.
The coup attempt began late Friday, with a military statement saying forces had seized control "to reinstall the constitutional order, democracy, human rights and freedoms, to ensure that the rule of law once again reigns in the country, for law and order to be reinstated."
Fighter jets buzzed overhead, gunfire erupted outside military headquarters and vehicles blocked two major bridges in Istanbul. Soldiers backed by tanks blocked entry to Istanbul's airport for a couple of hours before being overtaken by pro-government crowds carrying Turkish flags, according to footage broadcast by the Dogan news agency.
The military did not appear unified, as top commanders went on television to condemn the action and order troops back to their barracks.
CBS News correspondent Holly Williams reports that when government supporters had retaken control of Turkish state TV - and crowded into its studio - a newsreader said she was being held hostage by the coup plotters when she said earlier that a so-called "peace council" was in charge of the country to defend Turkey's democracy.
Erdogan, appearing on television over a mobile phone, had urged supporters into the streets to defend the government, and large crowds heeded his call.
People faced off with troops that had blocked the bridges over the Bosporus, linking the Asian and European sides of Istanbul.
By early Saturday, the putsch appeared to have fizzled, as police, soldiers and civilians loyal to the government confronted coup plotters.
In images broadcast on CNN-Turk, dozens of soldiers walked among tanks with their hands held up, surrendering to government forces. Discarded gear was strewn on the ground. Some flag-waving people climbed onto the tanks.
Colonels and generals implicated in the rebellion were fired and loyal troops rescued the military chief who had been taken hostage at an air base on the outskirts of Ankara, the capital.
Addressing large crowds after landing at Ataturk airport, Erdogan said of the plotters: "They have pointed the people's guns against the people. The president, whom 52 percent of the people brought to power, is in charge. This government brought to power by the people is in charge."
Fighting continued into the early morning, with the sounds of huge blasts echoing across Istanbul and Ankara, including at least one bomb that hit the parliament complex. Television footage showed broken glass and other debris strewn across a lobby leading to the assembly hall.
CNN-Turk said two bombs hit near the presidential palace, killing five people and wounding a number of others.
Turkey is a key partner in U.S.-led efforts to defeat ISIS, and has allowed American jets to use its Incirlik air base to fly missions against the extremists in nearby Syria and Iraq. A coup against the democratically elected government could have made it difficult for the United States to continue to cooperate with Turkey.
But Erdogan's Islamist government has also been accused of playing an ambiguous role in Syria. Turkey's renewed offensive against Kurdish militants - who seek an autonomous state and are implacable foes of ISIS - has complicated the fight against ISIS.
Government officials blamed the coup attempt on a U.S.-based Islamist cleric, Fethullah Gulen. Erdogan has long accused the cleric and his supporters of attempting to overthrow the government. Gulen lives in exile in Pennsylvania and promotes a philosophy that blends a mystical form of Islam with staunch advocacy of democracy, education, science and interfaith dialogue.
Fadi Hakura, a Turkey expert at the Chatham House think tank, said it was not clear who was behind the attempted coup, but it appeared to have been "carried out by lower-ranking officers - at the level of colonel."
"Their main gripe seems to have been President Erdogan's attempt to transform his office into a powerful and centralized executive presidency," Hakura said. He added: "this coup failed because it lacked popular support, political support and international support."
He predicted Erdogan will emerge stronger than ever.
"I think in the short term this failed coup plot will strengthen President Erdogan, particularly in his drive to turn his office into a strong and centralized executive presidency," he said.
Turkey's military staged three coups between 1960 and 1980 and pressured Prime Minister Necmettin Erbakan, a pious Muslim mentor of Erdogan, out of power in 1997.
There have long been tensions between the military - which saw itself as the protector of the secular Turkish state - and Erdogan's Islamic-influenced AKP party. Erdogan's government has taken steps, including dismissals and prosecutions of high-ranking active and former officers for alleged coup plots, to bring the military to heel.