US President Barack Obama on Friday urged all parties in Turkey to back the "democratically-elected" government, a clear denunciation of troops who launched a coup that has rocked the country.

Detailing a call between Obama and Secretary of State John Kerry, 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 Istanbul and Ankara, soldiers took to the streets as President Recep Tayyip Erdogan vowed the putschists would pay a "very heavy price."

Erdogan, speaking from what a presidential source said was a secure location, urged the population to resist the coup.

In a separate statement, Kerry said "the United States views with gravest concern events unfolding in Turkey. We are monitoring a very fluid situation."

"I spoke this evening to Foreign Minister (Mevlut) Cavusoglu and emphasized the United States' absolute support for Turkey's democratically-elected, civilian government and democratic institutions," he said.

"We urge all parties to ensure the safety and well-being of diplomatic missions and personnel and civilians throughout Turkey."