Updated at 10:00 am:
A coup attempt by factions in the Turkish military crumbled Saturday as President Recep Tayyip Erdogan made his way to Istanbul and his government began reestablishing control after a long night of widespread violence.
"The people have taken to the streets and voiced their support for democracy," the acting head of the military, Gen. Umit Dundar, said at a news conference Saturday. "The nation will never forget this betrayal."
The government and the military were focused Saturday on reasserting control and rounding of troops suspected of involvement in the coup. Prime Minister Binali Yildirim said 2,839 military personnel had been detained so far.
He put the death toll at 265, a figure that included civilians, soldiers and police loyal to the government, and coup plotters. More than 1,400 people were injured, he added.
Erdogan was on vacation in Marmaris when the coup plotters launched the revolt late Friday, igniting chaos in the streets and generating rapidly changing accounts of who was in charge.
The president, who has dominated Turkey for more than a decade, apparently escaped an attempt to detain or kill him and made his way to the Istanbul's Ataturk Airport in the early hours of Saturday, where a huge crowd of supporters greeted him.
"They have pointed the people's guns against the people," Erdogan said of the coup plotters. "The president, whom 52 percent of the people brought to power, is in charge."
The airport, the scene of a terror attack just last month that left more than 40 dead, was closed in the early hours of the coup attempt. But it returned to normal operations on Saturday.
Meanwhile, the fighting scarred a number of places around the country, including the parliament in Ankara, which was badly damaged after rebels reportedly carried out air strikes against the building.
The military chief of staff, Gen. Hulusi Akar, was rescued during an operation at an air base after being taken hostage earlier by pro-coup soldiers. Word that Akar had been taken hostage by the coup plotters was one of the early signs that not all the senior military officers were on board with the revolt.
The Turkish media on Saturday cited two military figures as leading the coup attempt. One was Gen. Akin Ozturk, who retired from the military last year after commanding the air force, though he continued to serve on the country's Supreme Military Council. The other was Lt. Gen. Metin Iyidil, the commander of combat and support training.
The rebels did seize a number of key locations in Ankara, the capital, and Istanbul, the largest city, in the early hours of the uprising. But as the revolt started to fall apart, they quickly lost control of spots like the Bosporus bridge in Istanbul. Early Saturday, CNN Turk showed video of dozens of coup soldiers surrendering there.
"Our president and government are in charge," the Turkish Embassy in Washington said in a statement, adding that the coup attempt "was conducted by a clique within the armed forces and received a well-deserved response from our nation."
U.S. Secretary of State John Kerry said Friday evening that he spoke with Turkey's foreign minister "and emphasized the United States' absolute support for Turkey's democratically elected, civilian government and democratic institutions."
When the coup attempt began, Erdogan's exact whereabouts were not clear. But the Turkish president — who has often censored and criticized social media — turned to FaceTime video and called on the Turkish people to resist the military action in an interview on CNN Turk.
"I urge the Turkish people to convene at public squares and airports," he said. "I never believed in a power higher than the power of the people."
Thousands of people soon flooded the streets in Turkish cities. TV footage showed large groups of unarmed civilians blocking the way of tanks and other military vehicles.
In a strange twist, Erdogan blamed the uprising on Fethullah Gulen, a prominent Muslim cleric who used to be a close ally of the president. But they had a falling out three years ago. Gulen has been living in Pennsylvania since the late 1990s.
"I have a message for Pennsylvania: You have engaged in enough treason against this nation. If you dare, come back to your country," Erdogan said Saturday, referring to Gulen.
Erdogan, who has ruled Turkey as either prime minister or president since 2003, has won several elections, most recently in 2014. But he's had a fraught relationship with the powerful military, which has carried out multiple coups over the past half-century.
Shortly after coup rumors began, a Turkish state television broadcaster read a statement saying members of the military had taken over the country. But from the beginning, it was not clear who within the military was behind the coup attempt, or how widespread support was in the military.
There were frequent reports of gunfire. In one instance, a military helicopter began shooting in Ankara. Reuters reported that a military jet shot down a military helicopter over the city, and that a bomb that exploded at the Parliament building.
The coup attempt raised a host of critical questions at a time when Turkey is engaged in turmoil at home and with neighboring countries.
Roughly half of Syria's nearly 5 million refugees are in Turkey, straining the country's resources. Turkey has also been the launching point for many Syrian refugees heading to Europe. And Turkey's security forces have been fighting Kurdish separatists in the southeast.
The U.S. works with Turkey on multiple crises in the region. To cite just one example, U.S. Air Force planes come and go from Turkey's Incirlik Air Base as they carry out airstrikes against the Islamic State in Syria. The U.S. military said its operations at the air base were not affected.
The U.S. State Department used Twitter to urge American citizens in Turkey to contact family and friends to assure others of their safety.
This is a breaking news story. We will update this post with further information as we have it.