ANKARA, Turkey - Forces loyal to Turkey's president quashed a coup attempt in a night of explosions, air battles and gunfire that left some 250 people dead and over 1,400 wounded Saturday. President Recep Tayyip Erdogan vowed that those responsible "will pay a heavy price for their treason" as authorities arrested or dismissed thousands of troops and judges.
The chaos Friday night and Saturday came amid a period of political turmoil in Turkey -- a NATO member and key Western ally in the fight against the Islamic State group -- that critics blame on Erdogan's increasingly authoritarian rule. Staying in power by switching from being prime minister to president, Erdogan has shaken up the government, cracked down on dissidents, restricted the news media and renewed fighting with Kurdish rebels.
The government has also come under pressure from hosting millions of refugees who have fled violence in neighboring Syria and Iraq, and from a series of bloody attacks blamed on Islamic State extremists and Kurdish rebels.
Erdogan was on a seaside vacation when tanks rolled into the streets of Ankara and Istanbul, blocking key bridges. From a cellphone, he delivered a televised address that called for huge crowds to come out and defend Turkey's democracy -- which they did in Ankara, the capital, and in Istanbul, facing off against troops who had blocked key Bosporus bridges that link the city's Asian and European sides.
Erdogan flew home early Saturday and declared the coup a failure. "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," he told large crowds after landing at Istanbul's Ataturk Airport.
Prime Minister Binali Yildirim described the night as "a black mark on Turkish democracy" and said the perpetrators "will receive every punishment they deserve." He also said July 15 will be remembered as "a festival for democracy," the day when those who carried out a coup against the people were hit by a coup themselves.
Late Saturday, Defense Minister Fikri Isik said state authorities were in full control of all areas in Turkey following the coup attempt but warned that authorities would remain vigilant.
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. Gen. Umit Dundar said the plotters were mainly officers from the Air Force, the military police and the armored units.
Turkey's four main political parties released a joint declaration during an extraordinary parliamentary meeting later Saturday, denouncing the coup attempt and claiming that any moves against the people or parliament will be met with the "with the iron will of the Turkish Grand National Assembly resisting them." The statement praised the Turkish nation for its unwavering belief in democracy and lauded citizens for taking to the streets and resisting the coup.
The death toll appeared to be over 250 people. Yildirim said 161 people were killed and 1,440 wounded in the process of putting down the coup attempt and 2,839 plotters were detained. A source at the office of the presidency, speaking on condition of anonymity in line with government rules, said the toll of 161 "excludes assailants." Dundar said at least 104 "coup plotters" had died.
Turkey's NATO allies lined up to condemn the coup attempt. President Barack Obama and German Chancellor Angela Merkel urged all sides to support Turkey's democratically elected government and Obama held a meeting with his national security advisers. NATO Secretary-General Jens Stoltenberg said he spoke to Turkish Foreign Minister Mevlut Cavusoglu and urged the Turkish people to respect democracy.
U.S. airline regulators banned all flights between the U.S. and airports in Ankara and Istanbul, including flights to the U.S. via third countries.
There have long been tensions between the military -- which sees itself as the protector of the secular Turkish state -- and Erdogan's Islamic-influenced AKP party.
Government officials blamed the coup attempt on a U.S.-based moderate Islamic cleric, Fethullah Gulen, whom Erdogan has often accused 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.
Gulen, however, said he condemned "in the strongest terms, the attempted military coup in Turkey" and sharply rejected any responsibility for it. "Government should be won through a process of free and fair elections, not force," he said. "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. I categorically deny such accusations."
Still, Erdogan's government pressed ahead Saturday with a purge of judicial officials, with 2,745 judges being dismissed across Turkey for alleged ties to Gulen, according to the state-run Anadolu news agency. It said 10 members of Turkey's highest administrative court were detained and arrest warrants were issued for 48 administrative court members and 140 members of Turkey's appeals court.
Among those detained for questioning were the commander of Turkey's second army, Gen. Adem Huduti, and a few other top aides in the eastern city of Malatya, Anadolu said.
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.
Top military commanders went on television to condemn the action and order troops back to their barracks. By early Saturday, the putsch appeared to have fizzled.