A Court of Appeals has ruled in favor of an inmate who has sued the state of Idaho for failing to give her gender reassignment surgery, making her the first to be given the procedure via a court order.

Adree Edmo, 31, got the go-ahead in December but attorneys for Idaho prison officials argued in May that the woman - who has been housed in a men's prison since she first began serving time on a charge of sexually abusing a child in April 2012 - is too mentally unstable to receive the irreversible medical procedure.

Edmo lived as a woman before going to Idaho State Correctional Institution in Kuna, but was diagnosed with gender dysphoria in June 2012.

She has tried to present herself as feminine while incarcerated, modifying her undergarments, styling her hair and wearing makeup.

Prison officials gave her disciplinary reports for those actions, however, and as a result she was denied parole, according to the lawsuit.

Edmo testified that she feels depressed, embarrassed and disgusted by her male genitalia.

The 9th Circuit Court of Appeals ruled that the state of Idaho must provide sex reassignment surgery to inmate Adree Edmo. Edmo would be the first transgender inmate in the nation to get it via court order

Edmo has been housed in a men's prison, Idaho State Correctional Institution in Kuna, since she first began serving time on a charge of sexually abusing a child younger than 16 in April 2012

In 2014, Edmo was so distressed that she tried to take her own life.

She received hormone therapy and counseling, but in 2015 she tried to castrate herself with a razor and failed.

In 2016 after studying anatomy, boiling her razor blade in an attempt to make it sterile and managing to remove one of her testicles before she began to lose too much blood and called for help, officials had her transported to a nearby hospital, where the testicle was repaired.

'I think the thing that makes this case so important is that this is a procedure that is necessary for some transgender inmates, and in fact is lifesaving care, but it's almost universally denied and banned by prisons across the country,' Amy Whelan, attorney with the National Center for Lesbian Rights, said.

She lived as a woman before prison but was diagnosed with gender dysphoria two months after being sentenced. Edmo's attorney said she was receiving hormone therapy and counseling but in 2015 she tried to castrate herself with a razor and in 2016 she removed a testicle

The original ruling in Idaho's U.S. District Court was handed down by Judge B. Lynn Winmill last December, who said the Idaho Department of Correction's refusal to provide Edmo with the surgery puts her at risk of irreparable harm.

Not all transgender people have gender dysphoria, Winmill noted in the original ruling, and not all transgender people desire or need surgery to make their physical body match their gender identity.

But for some, gender dysphoria - which occurs when the incongruity between a person's assigned gender and their gender identity is so severe that it impairs their ability to function - can only be fully addressed through surgery.

Amy Whelan, attorney with the National Center for Lesbian Rights, said gender reasignment surgery is 'lifesaving care'

Edmo's attorney, Lori Rifkin, had argued Idaho officials were treating Edmo's condition differently than they would any other medical concern. Prison officials wouldn't be allowed to refuse life-saving treatment to an inmate with a tumor, and they shouldn't be allowed to deny Edmo her needed treatment either, Rifkin said.

'They can say they were well meaning, but we have a person whose medical condition is being treated differently,' Rifkin said. 'A safe, established, effective treatment and they continue to deny it.'

In January, Republican Gov. Brad Little said in a prepared statement: 'The hard working taxpayers of Idaho should not be forced to pay for a prisoner's gender reassignment surgery when individual insurance plans won't even cover it.'

While gender reassignment surgery can cost as much as $100,000, under the state's contract with Corizon it might range between $20,000 and $30,000.

It's less than the $60,000 NPR reported the state paid one witness.

The Idaho Board of Correction Chairman, Dr. David McClusky, said the ruling judge confused its opinion with medical consensus.

'If Ms. Edmo had a broken arm, we'd all agree it should be treated,' McClusky, a surgeon, said in a statement. 'But disagreement among medical professionals in this case does not constitute cruel and unusual punishment.'

Bu appeals court judges said with their decision on Friday that 'responsible prison officials were deliberately indifferent to Edmo's gender dysphoria, in violation of the Eighth Amendment'.

She has been incarcerated seven years and is due to be released in July 2021.

The original ruling in Idaho's U.S. District Court was handed down by Judge B. Lynn Winmill (pictured) last December, but prison officials claimed she was too mentally unstable to receive the irreversible medical procedure in May's appeal

There are currently 40 inmates with gender dysphoria in state custody, according to the ruling. But between 60 and 70 are inmates are transgender.

Another transgender Idaho inmate, Jenniffer Spencer, sued the state more than 10 years ago after prison officials refused to diagnose or treat her.

Spencer requested treatment 75 times and finally attempted suicide. She then performed her own castration and nearly bled to death.

Only then did the department provide her with hormone therapy but would only give her male hormones, not the female hormones she sought.

In 2007, a federal judge ordered the state to provide Spencer with female hormone therapy.

The first inmate to receive the surgery was Shiloh Heavenly Quine, who is serving a life sentence for first-degree murder in California

Prison officials in California wrestled with the issue when inmate Michelle Lael Norsworthy sued for sex-reassignment surgery. But just one day before a federal appeals court was set to hear her case in 2015, the state paroled her, effectively ending the lawsuit.

The first inmate to receive the surgery was Shiloh Heavenly Quine, who is serving a life sentence for first-degree murder in California.

Prison officials there agreed in 2015 to pay for the procedure to settle a lawsuit brought by Quine and other transgender inmates.

The case also led California to become the first state to set standards that will allow other transgender inmate to apply for the surgery, and prompted a federal magistrate to require California to provide transgender female inmates housed in men's facilities with more female-oriented items like scarves and necklaces.

In March, the 5th U.S. Circuit Court of Appeals ruled against Texas inmate Vanessa Lynn Gibson in her lawsuit seeking gender confirmation surgery.

Circuit Judge James Ho said that while it is cruel and unusual punishment to deny essential medical care to an inmate, 'that does not mean prisons must provide whatever care an inmate wants'.