The jury cleared the jail on charges that its policies denied prisoners necessary care.

Ms. Sunderland likened her experience to the plight of the characters in Jon Krakauer’s book “Into Thin Air,” which she read in jail, about a doomed climbing expedition on Mount Everest. The book spoke to her.

“Sometimes people have an inborn, personal vision where they must do something, and they’ll risk everything to accomplish what they want,” she said. “People would say, Why would someone do all this just to climb a mountain? But to the climbers, it meant the world to them. Who I am in life — people say that’s not something someone should want to be. The way I see it is, that’s who I am. I’ll do whatever I can to achieve that, as strange as it seems to some people.”

Ms. Sunderland felt as early as age 4 that she was born into the wrong gender (she prefers feminine pronouns even in references to her childhood). She wore her sister’s dresses in private and worried about what other children thought of her. She liked her female self — “It was a good feeling,” she said — but felt a lot of anxiety and depression at home.

Her father, she said, was intimidating and critical, with a short temper she feared setting off.

By adolescence she thought she might be gay but did not have any gay friends; with her straight friends, she felt she didn’t belong.

“I wished I could just go someplace away and be who I want to be,” she recalled, “but not here.”

Like the climbers in “Into Thin Air,” she felt compelled toward something, but did not yet know how to get there. She dropped out of high school and used drugs to deal with the tensions in her body and at home. When that did not work, she took enough pills to black out and woke up in a hospital.

“I just couldn’t take it anymore,” she said in court, “and I didn’t see any other way of getting out of myself.”

Her life at home was stifling. She was in the wrong home, the wrong body, feeling increasing desire to transition, “like a weight” she was carrying around.