“The presidency does not interfere or comment on the judiciary,” the spokesman, Khaled al-Qazzaz, said in an e-mail.

Defense lawyers confirmed elements of Mr. Khater’s account. During last week’s fighting, thousands of Islamist supporters of the president battled similar numbers of his opponents for hours with thrown rocks and occasional gunshots, and Islamists captured and detained dozens of their opponents. It is unclear how many of the captors belonged to the Muslim Brotherhood or more hard-line groups. But videos, corroborated by the accounts of victims, indicated that the vigilante jailers tried to bully their prisoners into confessing that they were paid to use violence as part of a conspiracy against the president.

Mr. Khater wrote that around dawn the next day, he received a phone call from Mr. Morsi’s newly appointed public prosecutor, Talaat Ibrahim Abdullah, who said that “49 thugs” had been arrested and detained outside a gate to the palace. Mr. Khater said that when he arrived at the scene, the president’s chief of staff, Refaa al-Tahtawi, displayed guns, knives and other implements along with a document stating that the Islamists had confiscated the weapons from the captives.

All 49 captives had been beaten, Mr. Khater wrote, and they said members of the Muslim Brotherhood had tried to coerce them into confessing that they had taken money to commit violence. But prosecutors found no evidence that they had done so.

Even so, Mr. Morsi declared in a televised speech later that night that prosecutors had obtained confessions.

Officials from the chief prosecutor’s office requested a “firm” response in the case, Mr. Khater wrote, and the officials later pressed Mr. Khater to at least order the detention of a group of poor and unemployed prisoners.