A nearly two-decade legal fight by a convicted murderer in Massachusetts to get taxpayer-funded sex-reassignment surgery ended in failure Monday when the U.S. Supreme Court rejected her final appeal.

The justices did not comment in letting stand a lower-court ruling denying the surgery to Michelle Kosilek.

"This is a terrible and inhumane result for Michelle," said Jennifer Levi, director of the Transgender Rights Project for Boston-based Gay and Lesbian Advocates and Defenders.

The state Department of Correction, which has fought the surgery, did not immediately respond to a request to comment.

State prison officials, who say the surgery could cost as much as $50,000, have said in the past they opposed the surgery because it would create security problems.

Kosilek was known as Robert Kosilek when she was convicted of murdering her spouse, Cheryl, in 1990.

Kosilek, now 65, said in her legal fight against the state prisons department that her Eighth Amendment right against cruel and unusual punishment was being violated and the surgery is necessary to relieve the mental anguish caused by gender-identity disorder.

"The treatment of Michelle has been cruel and unusual, according to two lengthy, thoughtful, and closely reasoned judgments," Joseph Sulman, one of Kosilek's lawyers, said Monday. "The DOC's behavior has been abominable as they have repeatedly defied their own experts in their eagerness to deny her desperately needed medical attention."

The prisons department initially provided hormone treatments, electrolysis to remove facial and body hair, female clothing and personal items, but Kosilek sued again in 2005, arguing that the surgery was a medical necessity and denial of the surgery was making her suicidal. Her lawyers say she has twice tried to kill herself behind bars.

A federal judge in 2012 ordered the Department of Correction to grant the surgery, finding that it was the "only adequate treatment" for her gender-identity disorder. It was the first time a federal judge ordered such surgery.

But the state appealed and that ruling was overturned in December by the 1st U.S. Circuit Court of Appeals in a 3-2 decision, so Kosilek's lawyers turned to the Supreme Court.

The Boston Globe reported in Dec. 2014:

“After carefully considering the community standard of medical care, the adequacy of the provided treatment, and the valid security concerns articulated by the DOC [Department of Correction], we conclude that the district court erred,” Judge Juan R. Torruella wrote in the majority opinion.

Levi said even though Kosilek has exhausted all appeals, the fight for other inmates will continue.

"But it is just a matter of time before some prison somewhere is required to provide essential surgery, meeting the minimal Constitutional obligations of adequate medical care for transgender people in prison," she said.

Massachusetts Gov. Charlie Baker, a Republican who took office in January, said he was pleased with the decision.

"In this particular case I was not in favor of using taxpayer money to pay for this surgery," he said.

__

Associated Press writers Mark Sherman in Washington and Bob Salsberg in Boston contributed to this report.

Copyright 2015 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.