For more than 20 years, murder convict Michelle Kosilek has been requesting a sex change operation from prison officials. She is 64 years old, and though she remains anatomically male, she has long since stopped going by the first name Robert.

That means that for more than 20 years, she has not only lived behind bars but also been a prisoner of a body that she doesn’t identify with. After getting multiple denials ??of her official requests?? for a sex change, her legal "odyssey," as the U.S. Court of Appeals calls it, may have come to an end with that court's ruling Jan. 17.

In its opinion, the court wrote:

“In sum, where at least three eminently qualified doctors testify without objection, in accord with widely accepted, published standards, that Kosilek suffers from a life-threatening disorder that renders surgery medically necessary, and the factfinder is convinced by that testimony, we are at a loss to see how this court can properly overrule that finding of fact.“

The court went further in its opinion, saying Kosilek's case has wrongly become a flash point for "public and political opposition" to paying for the surgery—which can cost between $25,000 and $50,000—with taxpayer funds.

Kosilek spent part of her early years in an orphanage and “suffered regular abuse as a child, in part because of her expressed desire to live as a girl,” the opinion notes. Her rough adolescence was marked by “arrests, incarcerations, beatings, heavy drinking, drug use, and a stint as a prostitute.”

In the 1980s, Kosilek’s life took a turn for the straight and narrow. Particularly the straight. Kosilek was being treated at a drug rehab facility and living as a man when he married Cheryl McCaul, a volunteer at a drug rehab.

“McCaul thought she could cure Kosilek's gender identity disorder, but Kosilek's desire to be female did not go away. In 1990, Kosilek murdered McCaul,” the opinion said of the capital crime for which he was convicted. The crime resulted in a life sentence. Kosilek began taking female hormones while awaiting trial—and also tried to commit suicide twice in that time.

Since conviction, he has lived in a medium-security male prison in Massachusetts. While there, Kosilek has lived as a woman and fought for the ability to transition fully. She has been in that legal fight since 1992.

According to the court, being transgender is called “gender identity disorder” and is recognized as a “psychological condition” by the American Psychiatric Association in its Diagnostic and Statistical Manual of Mental Disorders. That may not be how activists would categorize a person's gender identity (and such a definition might be a battle for another day), but the categorization is what earned Kosilek treatment in the judge's ruling.

Kosilek's lawyer, Joseph Sulman, told the Associated Press that she was thrilled with the court's approval.

"This decision is really about more than sexual reassignment surgery," Sulman said. "It's about the state's requirement to treat all prisoners equally regardless of their gender identity or regardless of the circumstances."

“The Appeals Court affirmed that the District Court properly found that Michelle Kosilek needed this lifesaving medical care. If she needed treatment for cancer or heart disease, this case would never have wound up in court. If we are to call ourselves a civilized society, there is a baseline of care that has to be provided to all prisoners, including prisoners who are transgender,” said Jennifer Levi, director of GLAD’s Transgender Rights Project.

"We hope that Michelle will now get the treatment that she desperately needs."