"Go to the streets and give them their answer," he told residents during a Facetime interview on CNN Turk.
"I am coming to a square in Ankara. ... This was done from outside the chain of command," he said of the military. "Those who are responsible, we will give them the necessary punishment," he said. It was not clear where he was speaking from.
Earlier, Prime Minister Binali Yildirim told broadcaster A Haber that some military units have attempted a coup. Yildirim vowed the coup attempt would not succeed.
Photos:Military attempts coup in Turkey
He told state news agency Anadolu the coup is "an attempt against democracy and the will of the people. Those who attempted this will pay the heaviest price."
There have been no independent verification of the claims by the military or the government. It is unclear who is in charge in Turkey.
The military has issued statements, which have been published in some Turkish media, and not others, and reported by the Reuters news agency, claiming it has "fully seized control of Turkey" to maintain democratic order, that rule of law must remain a priority and international relations must remain. The statements have not been distributed through regular web channels.
A CNN producer said there were 200 to 300 residents in Taksim Square in Istanbul. Some of them were waving Turkish flags. About 100 police officers were shooting off tear gas, trying to disperse the crowd.
At least one army tank and one other military vehicle were at the square.
U.S. Secretary of State John Kerry told reporters in Moscow that he has been given reports about what is going on. "I don't have any details. I hope there will be peace, stability and continuity in Turkey," he said.
A report from the U.S. Embassy in Ankara said military-appearing jets had been flying low over the city and Istanbul for about an hour.
One tweet showed a military jet flying extremely low over the capital Ankara.
Two bridges in Istanbul are closed in one direction by the military. Cars are flowing from the European side of the city to the Asian, but soldiers and military vehicles are blocking the path to the European side.
Erdogan is the co-founder of Turkey's ruling Justice and Development Party (AKP). He was elected Prime Minister in 2003. Under his rule, Turkey became a powerhouse in the Middle East. His reign came to an end in 2014, and his own party's rules prevented him from seeking a fourth term.
So, he ran for president -- and won. Before this, the president of Turkey was a largely ceremonial role, but Erdogan tried to change that by altering the constitution to give him more power.
The 2015 election resulted in a hung Parliament, leading to sweeping anti-government protests and terror attacks. Turkey held a snap election, and with that, Erdogan's AK Party regained control.
Under Erdogan, who is extremely conservative, religion had started to play a more important role in Turkey, which is a largely secular country. He was active in Islamist circles in the 1970s and 1980s.
Erdogan is open about his dislike of social media. Sites such as YouTube and Facebook are frequently blacked out in the country.