In a dramatic development late Friday night, a group within Turkey's military attempted to overthrow the government and security forces.

Gunfire and explosions rocked both the main city Istanbul and capital Ankara in a chaotic night after soldiers took up positions in both cities and ordered state television to read out a statement declaring they had taken power, reported Reuters.

People take to streets near the Fatih Sultan Mehmet bridge during clashes with military forces in Istanbul on July 16 / AFP

In this attempted coup, 42 people were killed in Ankara, 17 of them being police officers.

However, the coup appeared to crumble in the early hours of Saturday after crowds answered President Tayyip Erdogan's call to take to the streets to support him, said this report.

Erdogan, who had been holidaying on the coast when the coup was launched, flew into Istanbul before dawn on Saturday and was shown on TV appearing among a crowd of supporters outside the airport, which the coup plotters had failed to secure.

Turkish President Tayyip Erdogan

The uprising was an "act of treason", and those responsible would pay a heavy price, he later told reporters at a hastily arranged news conference. Arrests of officers were under way, and it would go higher up the ranks, culminating in the cleansing of the military.

A successful overthrow of Erdogan, who has ruled Turkey since 2003, would have marked one of the biggest shifts in the Middle East in years, transforming one of the most important U.S. allies while war rages on its border. A failed coup attempt could still destabilise a pivotal country.

(It's a developing story)