ROME, Ga. — Right before her unexpected release from prison, Ashley Diamond, a nonviolent offender who had sued Georgia corrections officials for failing to provide her medical treatment and safekeeping, was locked down for 30 days in a windowless single cell. It was dimly lit and eerily silent, and reeked of excrement.

During that solitary confinement, which was ostensibly for her protection, she kept sane — though barely — by singing from dawn to dusk, especially Elton John songs: “Don’t let the sun go down on me,” she crooned to the graffiti-covered walls, even as she thought she would probably die, by her own hand or as a result of violence.

A transgender woman, Ms. Diamond, 37, had been housed in male prisons for more than three years, mocked and reprimanded for her gender identity, and deprived until this spring — after she filed suit and the Justice Department supported her case — of the feminizing hormones she had taken since adolescence. She had been sexually assaulted eight times, she alleges, and the contemplation of suicide, which she had attempted while in isolation previously, became a habit.

Ms. Diamond said she was stunned when Georgia freed her, on Aug. 31, months before she became eligible for parole. When her sister, mother and best friend picked her up at the Augusta State Medical Prison, she stiffened as they hugged her, overwhelmed by their ebullience. They stopped for a celebratory lunch, and she anxiously perused a Waffle House menu, asking, like a child, what she would be allowed to order.