A federal judge in Arkansas on Tuesday struck down the state’s law forbidding medical treatments for children and teenagers seeking gender transitions, blocking what had been the first in a wave of such measures championed by conservative lawmakers across the country.

The case had been closely watched as an important test of whether bans or severe restrictions on transition care for minors, which have since been enacted by 19 other states, could withstand legal challenges being brought by activists and civil liberties groups. It is the first ruling to broadly block such a ban for an entire state, though judges have intervened to temporarily delay similar laws from going into effect.

In his 80-page ruling, Judge James M. Moody Jr. of Federal District Court in Little Rock said the law both discriminated against transgender people and violated the constitutional rights of doctors. He also said that the state of Arkansas had failed to substantially prove a number of its claims, including that the care was experimental or carelessly prescribed to teenagers.

“Rather than protecting children or safeguarding medical ethics, the evidence showed that the prohibited medical care improves the mental health and well-being of patients and that by prohibiting it, the state undermined the interests it claims to be advancing,” wrote Judge Moody, who was nominated by President Barack Obama.

“Further,” he wrote, “the various claims underlying the state’s arguments that the act protects children and safeguards medical ethics do not explain why only gender-affirming medical care — and all gender-affirming medical care — is singled out for prohibition.”

The challenge to the law, which was brought by the American Civil Liberties Union of Arkansas and named several transgender children and a doctor as plaintiffs, argued that the ban violated transgender people’s constitutional rights to equal protection, parents’ rights to make appropriate medical decisions for their children and doctors’ rights to refer patients for medical treatments.

The decision was hailed as a significant victory for the L.G.B.T.Q. community, delivering a dose of certainty for transgender youth in Arkansas who had worried for nearly two years about losing access to puberty blockers and hormones. The ruling applies only to the Arkansas law, which Judge Moody had temporarily blocked just days before it was set to go into effect in July 2021.

Tim Griffin, the state’s attorney general, said he would appeal the decision, charging that the judge had overlooked concerns that the treatments were risky and unproven.

Gov. Sarah Huckabee Sanders, a Republican, backed the plans for an appeal, declaring that “this is not ‘care’ — it’s activists pushing a political agenda at the expense of our kids.”

The case in Arkansas has drawn widespread notice because the decision is a first on an issue that legal scholars say will be percolating through the courts for years, and could rise as high as the Supreme Court. “This is the beginning of what is likely going to be a significant, multistate national litigation battle over transgender rights,” said Joshua M. Silverstein, a law professor at the University of Arkansas at Little Rock.

Danielle Weatherby, a law professor at the University of Arkansas whose research has focused on legal issues facing transgender people, said the ruling “sets the tone that especially in a conservative state like Arkansas, legislatures can’t simply pass laws that infringe on citizens’ constitutional rights.”

The Arkansas law aimed to prevent doctors from administering hormone therapy or puberty blockers to transgender people younger than 18, and also barred gender transition surgeries. Doctors who provide transition care could lose their licenses or be subject to civil litigation under the law. They also would not be allowed to refer patients out of state for such care, and private insurers could refuse to cover transgender care for patients of any age.

The law’s authors argued that it was necessary because “the risks of gender transition procedures far outweigh any benefit at this stage of clinical study on these procedures.”

But opponents said that reasoning defied the position taken by much of the medical establishment, including the American Medical Association, which has criticized such bans as government intrusion into treatments that are medically necessary. Experts say that withholding gender transition care can carry dangerous consequences, including worsening distress for young people who already have a heightened risk of mental disorders and suicide.

The Williams Institute, an L.G.B.T.Q. research organization based at the law school of the University of California, Los Angeles, estimates that there are 1,800 transgender youths in Arkansas. In Little Rock, the Gender Spectrum Clinic at Arkansas Children’s Hospital serves fewer than 300 patients; it does not perform surgical procedures for gender transitions.

Judge Moody, who was overwhelmingly confirmed by the Senate in 2014, repeatedly cited the scientific evidence outlined by the law’s opponents, as well as the hours of testimony from doctors and transgender children and their families that described the painstaking decision-making process before beginning transition care.

“There is no evidence that the Arkansas health care community is throwing caution to the wind when treating minors with gender dysphoria,” he wrote, adding that “the state has failed to prove that its interests in the safety of Arkansas adolescents from gender transitioning procedures or the medical community’s ethical decline are compelling, genuine or even rational.”

The legislation had initially been vetoed by the governor at the time, Asa Hutchinson, a striking rebuke from a Republican who dismissed it as “well intentioned” but “off course.” But the veto was overridden by the legislature’s Republican supermajority.

Mr. Hutchinson, now a Republican presidential candidate who has cast himself as a traditional conservative alternative to former President Donald J. Trump, has stood by the veto, arguing that the law interfered with parents’ rights to decide what was best for their children.

The criticism has not daunted lawmakers eager to cut off minors’ access to gender transition treatments; some states have included even more restrictive measures than Arkansas’s in their bans. Alabama, for instance, passed a law that criminalizes the administration of transition care, threatening providers with up to 10 years in prison.

The laws are part of a broader campaign by Republican legislators who have zeroed in on issues of gender and identity. The lawmakers have pursued legislation that excludes transgender students from participating in school sports, forces them to use restrooms and locker rooms that align with the gender listed on their birth certificates and restricts what can be taught in classrooms about gender identity and sexual orientation.

Last month, Nebraska became one of the latest states to add restrictions on transition care for minors, and in Texas, Gov. Greg Abbott signed legislation to make the state the largest to ban hormone and puberty-blocking treatments, as well as surgeries, for transgender children. A law signed in May by Gov. Ron DeSantis of Florida went further, requiring adults seeking gender transition care to sign consent forms written by the state medical board and prohibiting nurse practitioners and physician assistants from prescribing hormone treatments for adult transgender patients.

But the legislation has prompted a corresponding flurry of legal challenges. In Alabama, a federal judge stopped the state from enforcing parts of a law that make it a felony to prescribe hormones or puberty-blocking medication while the court challenge continues. And in Florida, a federal judge recently issued a lacerating reproach of that state’s law, writing that the families suing over the ban were “likely to prevail” in their argument that it was unconstitutional and that “the rules were an exercise in politics, not good medicine.”

In Arkansas, Ms. Sanders, a Republican who succeeded Mr. Hutchinson, signed a bill in March that significantly expanded patients’ abilities to sue medical providers of transition care. Under the law, which goes into effect this summer, a patient would have a window of 15 years after turning 18 to take legal action; typically in Arkansas, a person has two years after an injury to pursue medical malpractice claims.

That legislation came as the state waited for Judge Moody’s decision. In a trial that included eight days of testimony, he heard from witnesses for the state who questioned the health consequences of transition treatments, as well as the scientific data cited in support of such care.

There was also testimony from transgender children and the doctors who worked with them, who described the transformative benefit of care that was administered responsibly and with a foundation of extensive medical evidence. At least one teenager testified that the realistic alternative would be leaving Arkansas.

“I’m so grateful the judge heard my experience of how this health care has changed my life for the better and saw the dangerous impact this law could have on my life and that of countless other transgender people,” said Dylan Brandt, a transgender teenager and a plaintiff in the case, in a statement released by the A.C.L.U.