TUNIS - Tunisia's president on Friday decreed a law imposing prison terms for spreading false information or rumours online, a move immediately denounced by the main journalists' union as an assault on freedom of speech.

President Kais Saied had said he would uphold the rights and freedoms won by Tunisians in a 2011 revolution that brought democracy after his moves last summer to seize most powers and shut down the elected parliament.

His new law on Friday, issued as a presidential decree, provided for prison terms of five years for spreading false news, false information or rumours with the aim of attacking others, harming public security or generating terror.

If the target of the false information or rumours is an official, the prison term can be 10 years, his new law said.

"The decree is a new setback for rights and freedoms. The penalties for publishing in any networks are a strong blow to the revolutionary values that granted freedom to all journalists and all Tunisians," said Mahdi Jlassi, the journalists' union head.

Jlassi added that the new law was reminiscent of those used by the late autocratic president Zine al-Abidine Ben Ali to crack down on dissenting opponents.

Since Tunisia's 2011 revolution, its media has become one of the most open of any Arab state, with even the state-owned news agency frequently reporting criticism of the authorities.

Activists on social media sites criticised Saied's decree, describing it as an effort to destroy those hard-won freedoms. Others mocked it, saying they would only publish sports news or art on their social media accounts.

Saied's critics accuse him of having launched a coup last summer when he seized executive authority, moving to one-man rule with a series of decrees that he enshrined in a constitution passed by a referendum in July.

Saied has denied acting unlawfully and says his actions were needed to save Tunisia from years of stagnation and political paralysis.

(Reporting by Tarek Amara; Writing by Angus McDowall; Editing by Cynthia Osterman)