Egyptian President Mohammed Morsi backed down from his decision to remove the country's top prosecutor at the weekend.
The two-day standoff between Mr Morsi and Prosecutor General Abdel-Meguid Mahmoud had escalated with a backlash from a powerful group of judges who said the president's attempt to remove the prosecutor had infringed their authority.
The standoff was later described as a "misunderstanding" by both sides but underlined President Morsi's fragile grip on power.
He had ordered Mr Mahmoud to step down on Thursday in a bid to appease public anger over the acquittals of former regime officials accused of orchestrating violence against protesters last year.
Egyptian law protects the prosecutor general from being sacked by the president so Mr Morsi asked Mr Mahmoud to become ambassador to the Vatican. But he refused.
Backed by the powerful Judges Club, Mr Mahmoud went to his office on Saturday in defiance, accompanied by a tight security escort and hundreds of supporters.
Hours later, Mr Mahmoud and members of the country's Supreme Judicial Council met presidential advisers.
"I remain in my post. We resolved the problem amicably," Mr Mahmoud said after the meeting. "We told him I wanted to stay and that there was a misunderstanding. He didn't object."
Vice-President Mahmoud Mekki claimed that the president had wanted to protect the prosecutor general from public pressure and protests and then cancelled the transfer to avoid "sedition."