Chief Judge Mark L. Wolf ruled Sept. 4 surgery is the "only adequate treatment" for Michelle Kosilek's gender identity disorder.
Kosilek, 63, previously known as Robert, was convicted of his wife's 1990 murder and has attempted to castrate and kill herself in the all-male Norfolk, Mass., prison, court records show.
"We are very disappointed that the commonwealth has decided to go in this direction," Massachusetts Transgender Political Coalition Executive Director Gunner Scott said Wednesday. "Care that is medically necessary for prisoners cannot be denied based on public opinion."
Wolf's ruling states there is "no less intrusive means to correct the prolonged violation of Kosilek's Eighth Amendment right to adequate medical care." He ordered the state to pay for Kosilek's legal fees.
Kosilek filed her first suit against prison officials in 2000.
The American Society of Plastic Surgeons says operations, therapy, hormone injections and electrolysis associated with sex reassignment surgery can cost from $30,000 to $80,000.
U.S. Sen. Scott Brown, R-Mass., called Wolf's ruling "an outrageous abuse of taxpayer dollars."
"I look forward to common sense prevailing and the ruling being overturned," Brown said in a statement.