A federal appeals court on Friday upheld a judge's ruling granting a taxpayer-funded sex change operation for a transgender inmate serving a life sentence for a murder conviction, saying receiving medically necessary treatment is a constitutional right that must be protected "even if that treatment strikes some as odd or unorthodox."

Michelle Kosilek, formerly known as Robert, in 1993 (AP File)

U.S. District Judge Mark Wolf ruled in 2012 that the state Department of Correction must provide sex reassignment surgery for Michelle Kosilek, who was born as Robert Kosilek and is serving a life sentence for the killing of his wife in 1990.

The Department of Correction challenged the ruling at the 1st U.S. Circuit Court of Appeals. Its lawyers argued Kosilek has received adequate treatment for gender identity disorder, including female hormone treatments, laser hair removal and psychotherapy. Prison officials said those treatments have eased the stress and anxiety felt by Kosilek, and they argued it was unnecessary to heed advice from independent medical experts who recommended the 64-year-old undergo the sex change surgery as the next step of treating her intense gender identity disorder.

The Department of Correction also argued prison officials were concerned about protecting Kosilek, who's in an all-male prison, from sexual assaults if she were allowed to complete her transformation into a woman.

Circuit Court of Appeals Judges O. Rogeriee Thompson and William Kayatta Jr. said in their ruling they were "assuredly mindful of the difficult tasks faced by prison officials every day."

"But as the Supreme Court has cautioned, while sensitivity and deference to these tasks is warranted, (c)ourts nevertheless must not shrink from their obligation to enforce the constitutional rights of all persons, including prisoners," the two judges wrote. "And receiving medically necessary treatment is one of those rights, even if that treatment strikes some as odd or unorthodox."

One member of the three-judge appeals panel disagreed. Judge Juan Torruella said in a separate opinion the ruling went beyond the boundaries of protections offered under the Eighth Amendment.

Still, Kosilek's lawyer Joseph Sulman said they were very happy her right to receive the treatment was affirmed.

"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 court, he said, agreed that "the state can't create obstacles and barriers for defendants' receiving adequate medical care simply because it's unpopular or simply because politicians and public officials don't agree with the medical professionals."

Kosilek was convicted of killing Cheryl Kosilek, a volunteer counselor at a drug rehabilitation facility who thought she could cure his gender identity disorder.

Kosilek first sued the Department of Correction in 2000. Two years later, the U.S. District Court judge found Kosilek was entitled to treatment for gender identity disorder but stopped short of ordering surgery. Kosilek sued again in 2005, arguing the surgery was a medical necessity.

Kosilek's attorney Frances Cohen had previously said the surgery, which can cost more than $50,000, would be paid for under a contract the Department of Correction has with its medical provider. She said the contract is based on the number of inmates, not the number of medical procedures provided, so the surgery wouldn't increase the state's costs.

Democratic Gov. Deval Patrick had no immediate comment on the appeals court ruling or whether a further appeal to the U.S. Supreme Court was possible, a spokeswoman said.