“Prison officials have the obligation to assess and treat gender dysphoria just as they would any other medical or mental health condition,” said Vanita Gupta, the Justice Department’s top civil rights prosecutor. “Freeze-frame policies can have serious consequences to the health and well-being of transgender prisoners, who are among the most vulnerable populations incarcerated in our nation’s prisons and jails.”

The Justice Department argued that denying Ms. Diamond an individual assessment and treatment plan violates the Eighth Amendment prohibition on cruel and unusual punishment. Under the Constitution, prisoners do not have a right to the medical care of their choosing, but must be provided adequate treatment for serious medical needs.

“Transgender inmates like Ashley have a right to proper medical care,” said Chinyere Ezie, a Southern Poverty Law Center lawyer who represents Ms. Diamond.

In 2005, Wisconsin passed an outright ban on hormone treatment for transgender inmates, regardless of whether the treatment was ongoing when they were arrested. Civil rights groups challenged the law on constitutional grounds and a federal appeals court overturned the law in 2011. Freeze frame policies are more common; civil rights groups say they exist in state and local jails around the country.

Until recently, the federal Bureau of Prisons also had a freeze frame policy. In 2011, the Obama administration settled a lawsuit over its policy and changed its guidelines. Treatment plans for federal inmates are now reviewed regularly and “hormone therapy may be a consideration,” regardless of whether the inmates received the treatment before being arrested.

In February, the Defense Department approved hormone therapy for Chelsea Manning, the former intelligence analyst convicted of providing classified documents to WikiLeaks. Ms. Manning, formerly known as Bradley Manning, was sentenced in 2013 to 35 years in prison. The day after the sentencing, she announced that she was a woman. A military court has recognized her as a woman.

With his action on Friday, Attorney General Eric H. Holder Jr., the nation’s first black attorney general, asserted that the campaign for the rights of gays, lesbians and transgendered people was a continuation of the movement that won equal rights for blacks in the civil rights era. He has been one of the Obama administration’s most outspoken voices on the issue of same-sex marriage, and he drew criticism from conservatives last year when he advised state attorneys general that they were not constitutionally obligated to defend bans on same-sex marriage.