US advises support for elected government, Iran calls for unity and Germany condemns attempts to alter democratic order.
An army group in Turkey declared a coup and martial law late on Friday, saying they had "taken control of the country". But thousands of peopled heeded a call by President Recep Tayyip Erdogan, taking to the streets to oppose the toppling of the government.
Turkish officials said on Saturday that more than 2,800 military personnel had been detained over the arrested coup that had failed.
Here is a selection of statements and reactions from Turkey and leaders around the world.
In a TV statement, the army group had said: "Turkish Armed Forces have completely taken over the administration of the country to reinstate constitutional order, human rights and freedoms, the rule of law and the general security that was damaged. All international agreements are still valid. We hope that all of our good relationships with all countries will continue."
In response, Turkish President Recep Tayyip Erdogan, in a FaceTime call to broadcaster CNN Turk, said he remained the leader of the country and the head of the army and called for people to take to the streets against the coup. "We will overcome this," he said, speaking on a video call to a mobile phone held up to the camera by a presenter. He called on his followers to take to the streets to defend his government and said the coup plotters would pay a heavy price. "I have never recognised any power above the will of the people," he said.
Speaking to thousands of jubilate supporters after arriving in Istanbul later on Saturday morning, Erdogan said the coup plotters had pointed "the people's guns against the people.
"The president, whom 52 percent of the people brought to power, is in charge," Erdogan said. "This government brought to power by the people, is in charge. They won't succeed as long as we stand against them by risking everything."
United Nations Secretary-General Ban Ki-moon has called for calm. The UN is seeking to clarify the situation.
US President Barack Obama urged all parties in Turkey to back the "democratically-elected" government. Detailing a call between Obama and Secretary of State John Kerry, who in Russia for talks on Syria, the White House said both agreed "all parties in Turkey should support the democratically-elected government of Turkey, show restraint, and avoid any violence or bloodshed".
In a statement, Russia's foreign ministry reiterated its readiness for joint constructive work with Turkey's legitimate leadership.
"The aggravating political situation against the backdrop of existing terrorist threats in this country and an armed conflict in the region pose increased danger to international and regional stability," it said.
Russia also called on its citizens in Turkey to stay indoors amid uncertainty about whether a military coup is taking place.
Britain's new Foreign Secretary Boris Johnson said he was "very concerned about the situation unfolding". He directed Britons to the Foreign and Commonwealth Office website, which advises "to avoid public places and remain vigilant" until the situation becomes clearer.
Iran's Foreign Minister, Javad Zarif, said "coups have no place in our region and are doomed to fail," on Twitter. "Deeply concerned about the crisis in Turkey Stability, democracy & safety of Turkish people are paramount. Unity & prudence are imperative," Zarif added in another tweet.
French Foreign Minister Jean-Marc Ayrault condemned the attempted coup, saying he hoped Turkey's "democracy will emerge strengthened". "The Turkish population showed its maturity and courage by committing to the respect of its institutions. It paid the price with many victims," he said in a statement.
Former Turkish President Abdullah Gul told CNN Turk that "Turkey is not a Latin America country ... I'm calling those who attempt to overthrow the government should go back to their barracks."
Turkey's history of military coups
Former Turkish Prime Minister Ahmet Davutoglu told Al Jazeera: "Turkey is a democracy ... I don't think this attempt will be successful." His voice shaking, he added: "There cannot be any attempts to destabilise Turkey. We're facing so many crisis in Syria and other regions, it's time to have solidarity with the Turkish people ... At this moment people in different cities are in the streets, the squares [protesting] against this coup d'etat attempt."
The head of the largest opposition party in Turkey, Kemal Kalicdaroglu, of the centre-left People's Republican Party (CHP), has come out against the coup in a series of tweets, saying the country has "suffered a lot" in past military takeovers.
The democratic order in Turkey must be respected and all must be done to protect lives, German Chancellor Angela Merkel's spokesman said on Twitter. Germany's Foreign Minister Frank-Walter Steinmeier also condemned "any attempts to change the democratic order in Turkey by force".
NATO chief Jens Stoltenberg hailed the "strong support" of democracy by the Turkish people. "I welcome the strong support shown by the people and all political parties to democracy and to the democratically elected government of Turkey," Stoltenberg said on Twitter.
European Council President Donald Tusk called on Saturday for a swift return to Turkey's constitutional order. "Turkey is a key partner for the European Union. The EU fully supports the democratically elected government, the institutions of the country and the rule of law," Tusk said at a regional summit in Mongolia. "We call for a swift return to Turkey's constitutional order," he said.
Slovakia, which holds the rotating European Union presidency, said it was following events and coordinating with EU partners. "Foreign Minister Miroslav Lajcak has been in intensive contact all evening with EU high Foreign Affairs representative Federica Mogherini and other European colleagues," the foreign ministry said in a statement. "He has also been in contact with partners in the Turkish government with the aim to clarify the situation in Turkey and discuss steps that the EU should take with the aim to maintain and support democracy and stability in the country."
India's foreign ministry said it was closely following the developments in Turkey. "India calls upon all sides to support democracy and mandate of the ballot and avoid bloodshed," the ministry said in a statement.
Qatar "expressed its strong denunciation and condemnation of the military coup attempt, lawlessness, and violation of the constitutional legitimacy in the Republic of Turkey", according to a foreign ministry statement.
Celebratory gunfire erupted in Syria's capital Damascus as word got out that there was an attempt to topple Erdogan, according to a Reuters news agency report. People took to the streets to celebrate there and in the government-held section of the divided city of Aleppo.
But a Turkey-based Syrian opposition group congratulated the Turkish people for stopping an attempted army coup. In a statement, the Syrian National Coalition said that Turkey protected its democratic institutions "in the face of dark and desperate attempts that sought to take control of the popular will".
Greek Prime Minister Alexis Tsipras was briefed on the coup and the country's military forces were holding emergency meetings, according to government officials.
Bulgaria bolstered its patrols on the Bulgarian-Turkish border and appealed to Bulgarians to restrain from travelling to Turkey, the government press office said in a statement. Prime Minister Boiko Borisov held talks with the security and intelligence services on the situation in Turkey, while the foreign ministry urged Bulgarians already in Turkey to stay indoors and avoid any public places.
Mexico's foreign ministry advised its citizens in Turkey to remain indoors, as it warned against travel to the country until the situation was clear.
The Turkish lira fell heavily after the coup attempt was launched, as much as 5.5 percent against the US dollar.