Egyptian President Abdel Fattah al-Sisi has approved an anti-terrorism law that sets up special courts and provides protections to its enforcers in the face of a two-year-long insurgency that aims to topple his government.

The law also details sentences for various terrorism crimes ranging from five years to the death penalty.

It also shields those applying it, such as the military and police, from legal ramifications for the proportionate use of force "in performing their duties."

Mr Sisi had promised a tougher legal system in July, after a car bomb attack that killed the top public prosecutor, the highest level state official to be killed in years.

Forming or leading a group deemed a "terrorist entity" by the government will be punishable by death or life in prison.

Membership in such a group will carry up to ten years in jail.

Financing "terrorist groups" will also carry a penalty of life in prison, which in Egypt is 25 years. Inciting violence, which includes "promoting ideas that call for violence" will lead to between five and seven years in jail, as will creating or using websites that spread such ideas.

Journalists will be fined for contradicting the authorities' version of any terrorist attack. The original draft of the law was amended following domestic and international outcry after it initially called for imprisonment for such an offence.

Egypt is facing an increasingly violent insurgency in North Sinai, where the most active militant group has pledged allegiance to Islamic State.

Cairo and other cities have also witnessed attacks.

The insurgency, which has killed hundreds of soldiers and police, has intensified since Mr Sisi, a former army chief, ousted the Islamist former President Mohamed Mursi after mass protests against his rule in 2013.

Amnesty International criticises legislation

The law has come under fire from human rights groups who accuse Mr Sisi of rolling back freedoms won in the 2011 uprising that toppled veteran autocrat Hosni Mubarak.

"This is taking us back to the Mubarak era and the 30-year state of emergency that helped push Egyptians to the streets in 2011," Mohamed Elmessiry, Egypt researcher at Amnesty International, said in a statement.

"Despite security forces having a record of excessive use of force, this law...paves the way for impunity."

Mr Elmessiry also said the law would in effect remove the current two-year limit on pre-trial detention by allowing prosecutors to ask to renew suspects' detention indefinitely.

"The law contravenes the Egyptian constitution and national laws, let alone international law," he said.