Egypt's state prosecutor Abdel Meguid Mahmud and President Mohamed Morsi agreed on Saturday that Mahmud will stay, ending a crisis over his refusal to quit after being dismissed, an aide to the prosecutor said.
State television reported that the two met and sealed an agreement under which "the state prosecutor will stay on in his post," said deputy state prosecutor Adel Said, citing a "misunderstanding over his nomination as ambassador to the Vatican."
Morsi on Thursday fired Mahmud, appointing him Cairo's envoy to the Vatican, but the state prosecutor refused to stand down, saying: "I remain in my post. According to the law, a judicial body cannot be dismissed by an executive authority."
The Islamist president's bid to remove Mahmud bypassed checks on presidential control of the prosecutor, enraging judges after Morsi also unsuccessfully tried to reverse a court order disbanding the Islamist-dominated parliament.
Morsi tried to remove the veteran prosecutor after this week's acquittals of Hosni Mubarak-era officials on trial for a deadly attack on protesters during the 2011 uprising that led to the long-time strongman standing down.
The verdicts triggered protests which culminated on Friday when supporters of Morsi clashed with his opponents in Cairo's emblematic Tahrir Square. The health ministry said 110 people were injured.
Activists who played a central role in last year's anti-Mubarak protests say that Mahmud was responsible for "weak evidence" provided by the prosecution in the case and is an old regime loyalist.
Signup to our newsletter and follow us on Facebook and Twitter!
Friday's protest was the worst violence over Morsi who emerged from the once banned but powerful Muslim Brotherhood to become Egypt's first Islamist and civilian president in June.
Since then, however, he has been the target of much criticism from opponents ranging from Mubarak loyalists to groups which spearheaded the revolt.
Mahmud on Friday said that he had received direct and indirect threats from a senior judge and an ally of Morsi who told him he could be assaulted if he did not step down.
The row between Mahmud and Morsi highlights a deep rift between the president and the powerful judiciary, which accuses the Islamist leader of trying to detract from their authority.
Ahmed al-Zind, head of the Judges' Club, on Friday was quoted as saying in the state-owned Al-Ahram daily that the judiciary was backing Mahmud to uphold "the sovereignty of the law and the principle of separation of powers."
Tensions have been rife in Egypt since Mubarak's ouster in the popular 18-day revolt in 2011, during which almost 850 people were killed.
Both Mubarak and his interior minister Habib al-Adly were jailed for life for their role in ordering the killings, but to the fury of activists, six top security chiefs who stood trial with them were acquitted.
Morsi had pledged to retry Mubarak and his senior officials for their roles in the killing of protesters during the revolt, amid mounting criticism that the trials had been bungled by the state prosecutor's office.