Turkey's president has declared a state of emergency for three months following a failed coup to oust his government.

President Recep Tayyip Erdogan said the measure was being taken to counter threats to Turkish democracy. He said the move was not intended to curb basic freedoms.

Speaking after a meeting of the National Security Council in Ankara lasting nearly five hours, he said the state of emergency was needed "to remove this threat as soon as possible".

In pictures: Turkey coup attempt Show all 17 1 /17 In pictures: Turkey coup attempt In pictures: Turkey coup attempt Turkish President Erdogan attends the funeral service for victims of the thwarted coup in Istanbul at Fatih mosque on July 17, 2016 in Istanbul, Turkey Burak Kara/Getty Images In pictures: Turkey coup attempt Soldiers involved in the coup attempt surrender on Bosphorus bridge with their hands raised in Istanbul on 16 July, 2016 Gokhan Tan/Getty In pictures: Turkey coup attempt A civilian beats a soldier after troops involved in the coup surrendered on the Bosphorus Bridge in Istanbul, Turkey, 16 July, 2016 REUTERS/Murad Sezer In pictures: Turkey coup attempt Surrendered Turkish soldiers who were involved in the coup are beaten by a civilian Reuters In pictures: Turkey coup attempt Soliders involved in the coup attempt surrender on Bosphorus bridge Getty In pictures: Turkey coup attempt Supporters of Turkish President Recep Tayyip Erdogan wave flags as they capture a Turkish Army vehicle Getty In pictures: Turkey coup attempt People pose near a tank after troops involved in the coup surrendered on the Bosphorus Bridge in Istanbul, Turkey, 16 July, 2016 Reuters In pictures: Turkey coup attempt Turkish soldiers block Istanbul's Bosphorus Brigde Getty In pictures: Turkey coup attempt A Turkish military stands guard near the Taksim Square in Istanbul Reuters In pictures: Turkey coup attempt Pierre Crom/Twitter In pictures: Turkey coup attempt Turkish soldiers secure the area as supporters of Recep Tayyip Erdogan protest in Istanbul's Taksim square AP In pictures: Turkey coup attempt People demonstrate in front of the Republic Monument at the Taksim Square in Istanbul Murad Sezer/Reuters In pictures: Turkey coup attempt Turkish soldiers detain police officers during a security shutdown of the Bosphorus Bridge Reuters In pictures: Turkey coup attempt Turkish Army armoured personnel carriers in the main streets of Istanbul Getty In pictures: Turkey coup attempt Chaos reigned in Istanbul as tanks drove through the streets EPA/TOLGA BOZOGLU In pictures: Turkey coup attempt Turkish President Tayyip Erdogan speaks to media in the resort town of Marmaris Reuters In pictures: Turkey coup attempt Supporters of President Erdogan celebrate in Ankara following the suppression of the attempted coup Reuters

He said: "The purpose of the declaration of the state of emergency is in fact to be able to take the most efficient steps in order to remove this threat as soon as possible, which is a threat to democracy, the rule of law and to the rights and freedoms of our citizens in our country."

"This measure is in no way against democracy, the law and freedoms," he added. "On the contrary it aims to protect and strengthen them."

The state of emergency, which comes into force after it is published in Turkey's official gazette, will allow the president and cabinet to bypass parliament in passing new laws and to limit or suspend rights and freedoms as they deem necessary.

Mr Erdogan said regional governors would receive increased powers under the state of emergency, adding that the armed forces would work in line with government orders.

"Europe does not have the right to criticize this decision," Erdogan added, seemingly anticipating concern from the European Union, which has become increasingly critical of Turkey and has urged restraint as Ankara purges its state institutions since the coup.

In his speech, Mr Erdogan expressed his “deepest gratitude” to citizens who took to the streets during the unrest in the country to show their support for his administration.

He described those who were killed fighting against the coup as “martyrs”, praising their “heroic bravery”.

An insurrection by some military units was launched on Friday, however it was quashed by security forces and protestors loyal to the government.

State Deptartment Denies US Behind Failed Coup in Turkey

The pro-government death toll in the botched coup has been estimated at 246. At least 24 coup plotters were also killed.

Mr Erdogan has warned of further arrests, sackings and suspensions as part of a far-reaching crackdown by Turkish authorities on those suspected of involvement in the coup.

Earlier on Wednesday, Turkey banned all academics from leaving the country, and ordered all those who are abroad to return immediately.

All teachers’ annual leave has been cancelled and those abroad have been given hours to return to Turkey where they must report for work at 8.30am on Thursday.

The orders follow the cancellation of the licences of 21,000 school teachers, and the forced resignation of 1,577 university deans.

More than 58,000 people in public sector roles are now estimated to have been arrested or thrown out of their jobs. Over 9,000 are in state custody.

The Turkish government confirmed that 6,500 employees at Turkey's education ministry had been suspended.