BOSTON (AP) — A federal judge on Tuesday ordered state prison officials to provide a taxpayer-funded sex-reassignment surgery to a transgender inmate serving life in prison for murder.

U.S. District Judge Mark Wolf ruled in the case of Michelle Kosilek, who was born as a man but has received hormone treatments and lives as a woman in an all-male prison. Robert Kosilek was convicted of murder in the killing of his wife in 1990.

Wolf is believed to be the first federal judge to order prison officials to provide the surgery for a transgender inmate.

Kosilek first sued the Massachusetts Department of Correction 12 years ago. Two years later, Wolf ruled that Kosilek was entitled to treatment for gender-identity disorder, but stopped short of ordering surgery. Kosilek sued again in 2005, arguing that the surgery is a medical necessity.

In his ruling Tuesday, Wolf found that surgery is the "only adequate treatment" for Kosilek's "serious medical need."

"The court finds that there is no less intrusive means to correct the prolonged violation of Kosilek's Eighth Amendment right to adequate medical care," Wolf wrote in his 126-page ruling.

Prison officials have repeatedly cited security risks in the case, saying that allowing her to have the surgery would make her a target for sexual assaults by other inmates.

But Wolf found that the DOC's security concerns are "either pretextual or can be dealt with by the DOC." He said it is up to prison officials to decide how and where to house Kosilek after the surgery.