A statement from the military, sent by email to Turkish media, said the armed forces have "fully seized control" of the country, while Turkish Prime Minister Binali Yildirim insisted the elected government remained in office.
"Some people illegally undertook an illegal action outside of the chain of command," Yildirim said in comments broadcast by private channel NTV. "The government elected by the people remains in charge. This government will only go when the people say so."
Turkish media reported that a Turkish Air Force F-16 fighter jet shot down a helicopter carrying "coup plotters."
The coup perpetrators explained their actions saying the coup was "to reinstall the constitutional order, democracy, human rights and freedoms, to ensure that the rule of law once again reigns in the country, for the law and order to be reinstated."
Their statement went on to say that "all international agreements and commitments will remain. We pledge that good relations with all world countries will continue."
If successful, the overthrow of Erdogan, who has ruled Turkey since 2003, would amount to one of the biggest shifts in power in the Middle East in years, transforming one of the most important US allies in the region while war rages on its border.
Erdogan, meanwhile, urged people to take to the streets to protest against what he described as a coup attempt by a minority faction within the military, vowing that it would meet with a "necessary response."
He told a CNN Turk reporter via cellphone that Turkish people must gather in public squares to show their response to the attempted military takeover, in comments broadcast live on television.
Erdogan said he believed the attempted coup would be over within a "short time" and said those responsible would pay a heavy price in the courts.
He said the act was encourage by the "parallel structure" - his shorthand for followers of Fethullah Gulen, a US-based Muslim cleric who he has repeatedly accused of attempting to foment an uprising among his followers in the judiciary and the military.
"We will overcome this," Erdogan said.
An official said Erdogan was speaking from Marmaris on the Turkish coast where he was on holiday. Erdogan said he would swiftly return to Ankara, while NBC reported he sought political asylum in Germany.
Turkish military takes over the streets
However, it appeared that those behind the coup had the upper hand initially as airports were shut and access to Internet social media sites was cut off across the country.
In Istanbul, tanks deployed at the city's main airport, where gunfire was reported. It was later reported the military had withdrawn from the airport while hundreds of Turkish civilians entered it.
Turkish troops also sealed off the two bridges over the Bosphorus in Istanbul. It was reported that soldiers opened fire on people trying to cross the bridges in protest of the attempted coup, some have been hurt.
Warplanes and helicopters roared over the capital Ankara, while the Dogan News Agency reported the national police directorate had summoned all police to duty in the Turkish capital.
Tanks surrounded parliament building in the capital and gunfire was sounded in the area. The Turkish Parliament speaker said in a TV interview that all political parties in the country were against the coup attempt.
A military helicopter attacked the Ankara police headquarters and the national intelligence headquarters. Anadolu reported 17 police officers were killed at the Ankara Special Forces headquarters. This report could not be independently confirmed.
Meanwhile, a senior Turkish official said the coup forces were taking to take over streets in Ankara and Istanbul and encountering "difficulties" in some areas. He estimated the insecurity will continue for the next 24 hours, but was confident it will be contained.
Soldiers took control of TRT state television, which announced a countrywide curfew and martial law. An announcer read a statement on the orders of the military that accused the government of eroding the democratic and secular rule of law. The country would be run by a "peace council" that would ensure the safety of the population, the statement said.
TRT later went off the air.
Despite the curfew announced by the military, thousands of Turks have reportedly gone out on the streets.
Meanwhile, the state-run Anadolu news agency said the chief of Turkey's military staff, General Hulusi Akar, was among people taken "hostage" by the coup perpetrators in the capital Ankara. CNN Turk also reported that hostages were being held at the military headquarters. Unconfirmed reports said Akar was killed.
The commander of Turkey's special forces said the armed forces did not condone the actions of the coup perpetrators. "A group has engaged in treason, they won't succeed," he said.
Celebrations in Damascus at reports of Erdogan's ouster
US Secretary of State John Kerry and Russian Foreign Minister Sergei Lavrov, speaking jointly after talks in Moscow, both said they hoped bloodshed would be avoided.
US President Barack Obama, meanwhile, called on all parties in Turkey to support the democratically-elected government, urging them to show restraint.
The US State Department said Americans in Turkey should shelter indoors. Other countries issued similar advice.
Turkey, a NATO member with the second biggest military in the Western alliance, is one of the most important allies of the United States in the fight against Islamic State (ISIS).
It is a principal backer of opponents of Syrian President Bashar Assad in that country's civil war, and host to 2 million Syrian refugees.
Celebratory gunfire erupted in Syria's capital Damascus as word got out that Erdogan had been toppled, and people took the streets to celebrate there and in the government-held section of the divided city of Aleppo.
The country has been at war with Kurdish separatists, and has suffered numerous bombing and shooting attacks this year, including an attack two weeks ago by Islamists at Istanbul's main airport that killed more than 40 people.
After serving as prime minister from 2003, Erdogan was elected president in 2014 with plans to alter the constitution to give the previously ceremonial presidency far greater executive powers.
His AK Party, with roots in Islamism, has long had a strained relationship with the military and nationalists in a state that was founded on secularist principles after World War One, and which has a history of military coups.
A senior EU source monitoring the situation said: "It looks like a relatively well orchestrated coup by a significant body of the military, not just a few colonels. They've got control of the airports and are expecting control over the TV station imminently. They control several strategic points in Istanbul.
"Given the scale of the operation, it is difficult to imagine they will stop short of prevailing. It's not just a few colonels," the source repeated.
One European diplomat was dining with the Turkish ambassador to a European capital when guests were interrupted by the pinging of urgent news on their mobile phones.
"This is clearly not some tinpot little coup. The Turkish ambassador was clearly shocked and is taking it very seriously," the diplomat told Reuters as the dinner party broke up. "However it looks in the morning, this will have massive implications for Turkey. This has not come out of nowhere."