CAIRO (AP) -- Egypt's president intervened to release a newspaper editor jailed over accusations of insulting him on Thursday, issuing a law for the first time since he assumed legislative powers earlier this month.

President Mohammed Morsi's ban on detention for journalists accused of publishing-related offenses overrides a court decision earlier in the day ordering newspaper editor Islam Afifi to remain in prison pending trial in September.

The court's decision and case against Afifi, accused of slandering the president and undermining public interest, has caused uproar in Egypt among journalists and intellectuals, with dozens holding a protest Thursday night in Cairo demanding the protection of free speech.

The decree affecting those awaiting trial for offenses such as libel, defamation and slander is the first law Morsi issued since taking over legislative authorities in the absence of a parliament, and following a decision to retire a cadre of generals with whom he had shared power earlier this month.

Morsi, who was sworn in as president in late June, issued the law just hours after a Cairo court ordered the imprisonment of Afifi, editor of the privately-owned el-Dustour daily. Egypt's official news agency reported shortly thereafter that the attorney general had ordered Afifi's release.

The case is one of several lawsuits brought mainly by Islamists against journalists in Egypt, accusing them of inflammatory coverage and inciting the public against the Muslim Brotherhood, Morsi's own movement and the country's most powerful political force.

El-Dustour regularly runs articles warning of alleged Brotherhood plots and conspiracies to turn Egypt into a fundamentalist Islamic state. It also has promoted an anti-Brotherhood demonstration for Friday, initially calling for the torching of Brotherhood offices but later toning down its call to peaceful rallies in Cairo.

Rights groups had expressed indignation at the court's decision to imprison Afifi, saying it betrayed the values of last year's revolt that deposed Hosni Mubarak, Egypt's longtime authoritarian president.

"This is a sad day for media freedom in Egypt because, for the first time since the January 2011 revolution, a professional journalist has been jailed for what he has written," the Paris-based Reporters Without Borders wrote in a statement. "The judicial authorities are trampling on the desire for freedom that the Egyptian people expressed during the 2011 and 2012 protests."

Youth activist Wael Ghonim, a former Google executive who played a key role in Egypt's uprising last year, wrote on Twitter that "insulting the president is a vague accusation that can be easily politicized."

"Tomorrow, when someone writes his opinion and calls Morsi a weak president ... he will be prosecuted for insulting the president," he added.

In the noisy court session earlier on Thursday, the head prosecutor from Cairo's Criminal Court had ordered Afifi held in custody and scheduled his trial for mid-September. He read out a long list of defamation charges including "insulting the president via a publication" and "spreading rumors that could disturb public safety and harm public interest."

Supporters of the defendant shouted in protest as the decision was read to the packed courtroom.

Pro-democracy activists have shown mixed reactions to the court cases. Many defend the right of freedom of expression and deem the Islamists' practices as repressive. Others side with the Islamists and accuse journalists facing trial of spreading propaganda in the service of former regime loyalists.

Another prominent case is that of TV presenter Tawfiq Okasha, who was accused of suggesting the murder of Morsi during a talk show aired on the private el-Faraeen TV station earlier this month.

The network was taken off the air and Okasha was banned from travel pending his trial in early September. Lawsuits have also been brought against chief editors of el-Fagr and Sawt el-Umma weeklies on similar accusations.

The Islamists, and especially the Brotherhood, have intensified their campaign against media they perceive as antagonistic, claiming they follow the former regime's agenda. The group feels empowered after Morsi became Egypt's first elected civilian president in modern history.

The call for protests against the Brotherhood on Friday has spurred public debate, especially after a Brotherhood cleric issued a religious edict, known as a fatwa, saying that killing anti-Islamist protesters was permissible.

Activists demand Morsi to take a strong stance against such statements. Presidential Spokesman Yasser Ali on Wednesday said the president supports the right to hold protests and said "it is unhealthy" to spread fears about protesters' safety.

Concerns of a possible showdown in Cairo have escalated. The Brotherhood asked its members to protect the group's offices from opposition protesters on Friday. Security authorities warned in a statement that they would "confront with all firmness ... riots or chaos that harms citizens' interests."

Leading pro-democracy advocate Mohamed ElBaradei said the developments in Egypt are "as if no revolution has taken place."

Although the lower house of parliament, which drafts laws, was dissolved this year, the Brotherhood-led upper chamber of parliament known as the Shura Council continues to function. The council controls state-owned newspapers and last month ordered the dismissal of 50 chief editors, many viewed as regime loyalists.

The appointment of new editors, who are either sympathizers of the Islamists or members of the Brotherhood, sparked a wave of protests by journalists both within and outside state media. The national journalist association known as The Press Syndicate accused the Brotherhood of trying to monopolize the media and turn it into its mouthpiece.


Associated Press correspondent Aya Batrawy contributed to this report.