About 1,000 demonstrators gathered around Tahrir Square at night to protest the decision, but heavily armed security forces had closed off the traffic circle. By 9 p.m., the police were firing tear gas and birdshot to drive away the crowds, and by midnight state news media reported that at least one person had been killed and more than 85 were arrested.

More than five months after the inauguration of a military-backed strongman, President Abdel Fattah el-Sisi, the authorities appeared to calculate that the Egyptian public was so weary of unrest that it had lost a desire for retribution against Mr. Mubarak, or at least that they now had a firm enough grip to suppress any backlash.

“Today’s verdict indicates a very deliberate decision by the regime to continue on the path of rewriting the history that led to Mubarak’s ouster and closing the file on the Jan. 25 revolution,” said Hossam Bahgat, a journalist and human rights advocate who had cheered on that revolt and is now studying in New York.

The council of generals who took power from Mr. Mubarak had feared a public backlash too much to ever allow the former president’s release, but Mr. Sisi’s government felt no such compunction, Mr. Bahgat said. “They are not afraid. They are perfectly capable of letting him walk free, and they feel no pressure to hold him accountable.”

Mr. Mubarak, 86, who has been held at a military hospital because of frail health, appeared in court on a stretcher in sunglasses, a blue necktie and sweater. He remained stone-faced as the chief judge, Mahmoud Kamel al-Rashidi, read the verdict. Only at the end did he allow himself a smile as his two sons, Alaa and Gamal, hugged and kissed him.