Robert Kosilek, Michelle Kosilek

In this Jan. 15, 1993 file photo, Michelle Kosilek, sits in Bristol County Superior Court, in New Bedford, Mass. A federal appeals court on Tuesday, Dec. 16, 2014, overturned a 2012 ruling ordering Massachusetts prison officials to provide taxpayer-funded sex-reassignment surgery for the inmate born as Robert Kosilek, who had been convicted of murdering his wife in 1990. (AP Photo/Lisa Bul, File)

(Lisa Bul)

BOSTON -- A divided federal appeals court on Tuesday overturned a ruling ordering Massachusetts prison officials to provide taxpayer-funded sex-reassignment surgery for an inmate convicted of murder.

Michelle Kosilek, born Robert Kosilek, is serving a life sentence for killing spouse Cheryl Kosilek in 1990. Kosilek has waged a protracted legal battle for the surgery she says is necessary to relieve the mental anguish caused by gender-identity disorder.

In 2012, U.S. District Judge Mark Wolf became the first judge in the country to order sex-reassignment surgery as a remedy for an inmate's gender-identity disorder. Courts around the country have found that prisons must evaluate transgender inmates to determine their health care needs, but most have ordered hormone treatments and psychotherapy, not surgery.

Wolf's decision was upheld by a three-judge panel of the 1st U.S. Circuit Court of Appeals, but prison officials appealed and won a rehearing before the full appeals court.

In a 3-2 ruling Tuesday, the full 1st Circuit found that Kosilek failed to demonstrate that prison officials violated the Eight Amendment prohibition against cruel and unusual punishment by not providing the surgery.

The court noted that the state Department of Correction has provided treatment for Kosilek's gender-identity disorder, including female hormones, laser hair removal and psychotherapy. The court also noted the department's concerns about protecting Kosilek from sexual assaults if she completes her gender transition. She is currently housed in a male prison but hoped to be transferred to a female prison after the surgery.

"After carefully considering the community standard of medical care, the adequacy of the provided treatment, and the valid security concerns articulated by the DOC, we conclude that the district court erred and that the care provided to Kosilek by the DOC does not violate the Eighth Amendment," Judge Juan Torruella wrote for the majority.

Two judges disagreed with the majority. In a sharply worded dissenting opinion, Judge Ojetta Rogeriee Thompson suggested that Kosilek would not have had to fight a long battle for constitutionally adequate medical care if she was not seeking "a treatment that many see as strange or immoral."

"Prejudice and fear of the unfamiliar have undoubtedly played a role in this matter's protraction," Thompson wrote.

Massachusetts Public Safety Secretary Andrea Cabral said the state acknowledges "the legitimacy of a gender identity disorder diagnosis," but said the Department of Correction's appeal was based on security concerns and on the lower court's "significant expansion of the standard for what constitutes adequate care under the Eighth Amendment."

The case sparked a heated debate in Massachusetts, where Kosilek's lawsuit became fodder for radio talk shows and state lawmakers who say the state should not be forced to pay for or provide a murderer's sex-reassignment surgery.

In his ruling ordering the surgery, Wolf found that it is the "only adequate treatment" for Kosilek.

Kosilek, now 65, told The Associated Press in 2011 that the surgery is a medical necessity.

"Everybody has the right to have their health care needs met, whether they are in prison or out on the streets," Kosilek said.

"People in the prisons who have bad hearts, hips or knees have surgery to repair those things. My medical needs are no less important or more important than the person in the cell next to me."

Kosilek's lawyer, Joseph Sulman, said he was extremely disappointed in the ruling but said no decision has been made yet on whether to ask the U.S. Supreme Court to hear the case.

"The appellate court improperly second-guessed the fact-finding made by the district court," Sulman said. "It creates an effective rule that allows prison officials to hire an expert to deny a prisoner medical treatment. That's the result of this decision."

Jennifer Levi, director of the Transgender Rights Project of the Boston-based legal group Gay & Lesbian Advocates & Defenders, said she was appalled by the ruling.

"If somebody had a heart condition, if somebody had liver disease, if somebody had diabetes ... under the constitutional principles applied to all people who are incarcerated, that person would be entitled to essential medical care," Levi said.

"It really is hard to understand this decision as anything other than transgender exceptionalism."