Turkish authorities rounded up nearly 3,000 suspected military plotters on Saturday and ordered thousands of judges detained after thwarting a coup by rebels using tanks and attack helicopters to try to topple President Tayyip Erdogan.

For several hours overnight on Friday violence shook Turkey's two main cities, as the armed faction which tried to seize power blocked a bridge in Istanbul and strafed the headquarters of Turkish intelligence and parliament in Ankara.

At least 265 people were killed. An official said 161 of them were mostly civilians and police officers, while the remaining 104 were coup supporters.

People apprehend a Turkish soldier, third right in blue, that participated in the attempted coup (AAP) People apprehend a Turkish soldier, third right in blue, that participated in the attempted coup (AAP)

But the coup attempt crumbled as Erdogan rushed back to Istanbul from a Mediterranean holiday and urged people to take to the streets to support his government against plotters he accused of trying to kill him.

"They will pay a heavy price for this," said Erdogan, launching a purge of the armed forces, which last used force to stage a successful coup more than 30 years ago. "This uprising is a gift from God to us because this will be a reason to cleanse our army."

Among those detained were top military commanders, including the head of the Second Army which protects the country's borders with Syria, Iraq and Iran, state-run Anadolu news agency said.

Read full story