Turkey's Prime Minister Binali Yildirim addresses members of parliament from his ruling AK Party (AKP) during a meeting at the Turkish parliament in Ankara, Turkey, November 8, 2016. REUTERS/Umit Bektas

ANKARA (Reuters) - Turkey’s parliament voted overnight to extend emergency rule by three months in a move which the government said was needed to sustain a purge of supporters of the U.S.-based Muslim cleric accused of orchestrating July’s failed coup, state media said.

Emergency rule, first imposed in Turkey after an attempted putsch on July 15 and then extended in October, enables the government to bypass parliament in enacting new laws and to limit or suspend rights and freedoms when deemed necessary.

The extension, effective from Jan. 19, comes as Turkey reels from a series of attacks by Islamist or Kurdish militants, most recently on Sunday when a lone gunman shot dead 39 people in an Istanbul nightclub during New Year celebrations.

Ankara accuses Pennsylvania-based preacher Fethullah Gulen and his supporters, whom it terms the Gulenist Terror Organisation (FETO), of being behind the July coup attempt. Gulen denies the allegations.

“The purge of FETO from the state has not been completed. We need the implementation of emergency rule until FETO and all terror groups have been purged from the state,” Deputy Prime Minister Numan Kurtulmus said in parliament ahead of the vote.

More than 41,000 people have been jailed pending trial in connection with the attempted coup out of 100,000 who have faced investigation. Some 120,000 people, including soldiers, police officers, teachers, judges and journalists, have been suspended or dismissed since the coup, although thousands of them have since been restored to their posts.