A federal appeals court in San Francisco on Monday affirmed its ruling, the first by any appellate court, ordering a state to provide gender-confirmation surgery to a transgender inmate. Ten Republican-appointed judges dissented, including the court’s first openly gay judge.

The Idaho inmate, Adree Edmo, was born male but says she has viewed herself as female since age 5 or 6 and began living as a woman at about 20 or 21. Sexually abused as a child, she pleaded guilty in 2012, at age 21, to sexual abuse of a 15-year-old boy at a house party. She is due to be released from prison next year.

Prison doctors diagnosed her with gender dysphoria, the searing emotional stress from a conflict between birth sex and gender identity, and prescribed hormones. Housed at a men’s prison, Edmo attempted to castrate herself with a razor blade in 2015. She applied for surgery in 2016 but the prison’s chief physician and medical staff turned her down, saying the hormone therapy had lessened her dysphoria and that she had refused to attend other therapy sessions.

Edmo sued and won support from medical experts, including psychologist Randi Ettner, an author of the World Professional Association of Transgender Health’s Standards of Care, known as WPATH. They said she met their standards for gender-confirmation surgery, including persistent gender dysphoria, at least a year of hormone therapy and the capacity to make an informed decision.

A federal judge in Idaho ruled in her favor, accepting WPATH’s testimony and finding that the state’s physicians lacked credibility. A three-judge panel of the Ninth U.S. Circuit Court of Appeals upheld that ruling in August, saying the evidence supported the judge’s conclusion that “prison authorities have been deliberately indifferent to Edmo’s gender dysphoria,” violating the constitutional ban on cruel and unusual punishment.

The prison physicians asked the full appeals court for a rehearing and were turned down Monday despite dissents from a majority of the Republican appointees on the 29-judge court. One dissent came from Patrick Bumatay, a former federal prosecutor who became the court’s first openly gay judge when he was nominated by President Trump and confirmed by the Senate in December.

“I hold great sympathy for Adree Edmo’s medical situation,” but courts must apply the Constitution, “not our sympathies,” wrote Bumatay, whose opinion was joined by six colleagues.

He said the Eighth Amendment’s prohibition on cruel and unusual punishment was intended to apply only to deliberate infliction of unnecessary pain and suffering. Edmo’s case involves only a difference of medical opinion, Bumatay said, and Idaho’s denial of the surgery does not constitute “the barbarous or inhuman treatment so out of line with longstanding practice as to be forbidden by the Eighth Amendment.”

In a separate dissent, Judge Diarmuid O’Scannlain, joined by Bumatay and seven other judges, said the August ruling “substitutes the medical conclusions of federal judges for the clinical judgments of prisoners’ treating physicians.”

O’Scannlain said WPATH was not an established authority, but merely “a controversial private organization with a declared point of view.” And he said the ruling created a split between appellate courts, since the Fifth U.S. Circuit Court of Appeals in New Orleans refused to order the surgery in a separate case last year, a ruling that the Supreme Court later declined to review.

Idaho’s Republican governor, Brad Little, said he would ask the Supreme Court to overturn the ruling in Edmo’s case. He said he was encouraged by the dissenting opinions, and was committed to “ensuring that Idaho taxpayers do not have to pay for a procedure that is not medically necessary.”

Meanwhile, Edmo’s attorney, Lori Rifkin of Berkeley, said Monday’s court order moved her client one step closer to surgery.

The ruling was based on testimony by “the only recognized expert in the field,” Rifkin said. “Science indicates that this is a medical condition. There is a medical treatment. The Eighth Amendment has required for decades that prison officials provide necessary medical treatment.”

Bob Egelko is a San Francisco Chronicle staff writer. Email: begelko@sfchronicle.com Twitter: @BobEgelko