KHARTOUM, Sudan — Mohamed Morsi, Egypt’s first democratically elected president, collapsed and died while on trial in a Cairo courtroom on Monday, six years after the military ousted him in tumultuous circumstances that pushed Egypt back to autocratic rule.

The Egyptian authorities gave no official cause of death, but critics blamed the poor conditions in the prison where Mr. Morsi had spent the past six years. They said the authorities had deprived him of vital medicine for diabetes, high blood pressure and liver disease; held him in solitary confinement for long periods; and ignored repeated public warnings that the lack of proper medical care could be fatal.

“I think there is a very strong case to be made that this was criminal negligence, deliberate malfeasance in providing Morsi basic prisoner rights,” Sarah Leah Whitson, the executive director for the Middle East and North Africa at Human Rights Watch, said Monday. “He was very obviously singled out for mistreatment.”

His death was a somber milestone in Egypt’s ill-fated democratic transition after the Arab Spring in 2011.