NEW DELHI: Military factions in Turkey attempted a coup on Friday night, plunging the country into chaos.

Martial law was declared as President Recep Tayyip Erdogan was forced to take to Facetime from an undisclosed location. "This was done from outside the chain of command," he said, adding that lower officers had rebelled against senior officers. "Those who are responsible, we will give them the necessary punishment," Erdoğan told CNN Turk via mobile.

Meanwhile, the rebelling military faction announced on TV that it was in control of the country, with soldiers at strategic points in Istanbul and jets flying low in the capital, Ankara. A statement read on TV said a "peace council" now ran the country and there was a curfew and martial law.

The military also issued a statement claiming it had control of the country, reports news agency DHA. “Turkish armed forces seized the rule of the country completely with the aim of reinstalling the constitutional order, democracy, human rights and freedoms, to make rule of law pervade again, to re-establish the ruined public order,” the statement quoted by DHA said. “All the international agreements and promises are valid. We hope our good relations with all global countries goes on.”

At the time of writing, it is unclear who exactly the rebelling group is comprised of. Some top army officials are said to be detained. Reports suggest that Turkey's top general, General Hulusi Akar, is among those taken hostage at the military headquarters.

Erdogan blamed the coup attempt on followers of Fethullah Gulen, a Muslim cleric who lives in exile in Pennsylvania and who once was an ally before the two had a bitter falling-out in 2013 over a corruption inquiry that targeted Erdogan’s inner circle. The coup attempt comes as Turkey -- a NATO member and a US ally -- sees a wave of deadly attacks claimed by the Islamic State as well as dissent brewing amongst minority Kurds in the country.

Turkish Prime Minister Binali Yildirim had earlier denounced an "illegal action" by a military "group", stressing it was not a coup. He said that the government remained in charge.

The US embassy issued a statement saying “that shots have been heard in Ankara and both bridges in Istanbul, Bosphorous and Fatih Sultan Mehmet, are now closed. The Turkish Government states that elements of the Turkish army are attempting an uprising, security forces are taking action to contain it, and some buildings are under blockade.”

Reports suggest that the events began unfolding late on Friday night, at about 10 PM as he military moved to stop traffic over two of Istanbul’s bridges, which cross the Bosporus and connect the European and Asian sides of the city. Skirmishes broke out between Erdogan’s supporters and those backing the coup, reports suggest.

Erdogan has received support from Turkey’s opposition parties. “This country had suffered a lot from the coups. We do not these difficulties be repeated,” Kemal Kılıçdaroğlu, the leader of the Republican People’s Party (CHP) said in a written statement. He added that “it should be known that the CHP fully depends on the free will of the people as indispensable of our parliamentary democracy.”

Nationalist Movement Party (MHP) leader Devlet Bahçeli phoned PM Binali Yıldırım after news broke, expressing his party’s support.

US President Barack Obama also pledged support to the Turkish government. “The President and Secretary agreed that all parties in Turkey should support the democratically-elected Government of Turkey, show restraint, and avoid any violence or bloodshed. The Secretary underscored that the State Department will continue to focus on the safety and security of U.S. citizens in Turkey," the statement form the White House said.

At the time of writing, it is after 2 AM in Turkey and crowds are flooding onto the streets, gathering the Bosphorus Bridge and Taksim Square. Reports suggest that they are heeding the request from president to resist the coup. The crowds are defying a command from the military -- which has implemented a curfew and declared martial law.

Meanwhile, news broke that at least 17 policemen were killed in an attack on Golbasi Special Operations headquarters in Ankara as a helicopter fired on their positions. Details are still emerging.

Turkey has a history of coups. A timeline includes:

1993 - Claims of a "covert coup" intended to prevent a peace settlement with the Kurdistan Workers' Party (PKK)

1980 - Military coup following armed conflict between right-wing and left-wing groups in the 1970s

1971 - Military coup known as the "coup by memorandum", which the military delivered instead of sending out tanks

1960 - Coup by group of young military officer outside chain of command, against the democratically-elected Democrat Party

(This is a developing story. It was last updated at 5 30 AM Indian Standard Time).