Children under 16 with gender dysphoria are unlikely to be able to give informed consent to undergo treatment with puberty-blocking drugs, three High Court judges have ruled.
The case was brought against Tavistock and Portman NHS Trust, which said it was "disappointed" but immediately suspended such referrals for under-16s.
The NHS said it "welcomed the clarity" the ruling would bring.
One of the claimants, Keira Bell, said she was "delighted" by the judgment.
Ms Bell, 23, from Cambridge, had been referred to the Tavistock Centre, which runs the UK's only gender-identity development service (GIDS), as a teenager and was prescribed puberty blockers aged 16.
She argued the clinic should have challenged her more over her decision to transition to a male as a teenager.
In a ruling, Dame Victoria Sharp, sitting with Lord Justice Lewis and Mrs Justice Lieven, said: "It is highly unlikely that a child aged 13 or under would be competent to give consent to the administration of puberty blockers.
"It is doubtful that a child aged 14 or 15 could understand and weigh the long-term risks and consequences of the administration of puberty blockers."
They added: "In respect of young persons aged 16 and over, the legal position is that there is a presumption that they have the ability to consent to medical treatment.
"Given the long-term consequences of the clinical interventions at issue in this case, and given that the treatment is as yet innovative and experimental, we recognise that clinicians may well regard these as cases where the authorisation of the court should be sought prior to commencing the clinical treatment."
The second claimant, known only as Mrs A, is the mother of a 15-year-old girl with autism, who is awaiting treatment at the clinic.
Speaking to the BBC prior to Tuesday's ruling, she said: "My fear is - it's not that she transitions - it's that she gets it wrong."
She said it was "frightening" there was so little exploration of why a child might be feeling they were the wrong sex before puberty blockers were given.
"It is distressing to have to wait and to try and convince someone that your identity warrants medical intervention. However, I think the downside of getting it wrong, the outcomes of getting it wrong, are also catastrophic."
At a High Court hearing in October, lawyers representing the claimants said there was "a very high likelihood" children who start taking hormone blockers will later begin taking cross-sex hormones, which they say cause "irreversible changes".
The trust - as well as University College London Hospitals NHS Foundation Trust and Leeds Teaching Hospital NHS Trust, to which Tavistock refers children and young people experiencing gender dysphoria - argued taking puberty blockers and later cross-sex hormones were entirely separate stages of treatment.
'It was heartbreaking to realise I'd gone down the wrong path'
Growing up, Keira Bell felt confused and distressed by her body.
At 16, she became one of thousands of girls, some as young as 10 or 11, referred to the Tavistock and Portman Trust.
After three one-hour appointments she was prescribed puberty blockers before she was put on testosterone.
"When I was 20 I had a double mastectomy," she said.
She believed the treatment would help her "achieve happiness".
Ms Bell, who began de-transitioning last year, said: "It was heartbreaking to realise I'd gone down the wrong path."
The judges said their decision was only on the informed consent of a child or a young person, not whether puberty blockers were appropriate themselves.
The ruling said: "The court is not deciding on the benefits or disbenefits of treating children with GD (gender dysphoria) with PBs, whether in the long or short term."
This is a complex area of treatment that holds at its heart the future lives and happiness of some very vulnerable children, so today's judgment will be greeted with both sighs of relief and cries of anguish.
For the first time the ruling places a strong legal framework around the prescribing of puberty blockers.
The judges have effectively split the issue into stages. They concluded a child under 13 is "highly unlikely" to be able to give informed consent and at 14 and 15 it is still "doubtful" they can fully understand the implications of the medication.
Even for 16 and 17-year olds the ruling says it may be appropriate to involve the courts in the decision.
The judges point to the lack of evidence about the long-term effects of puberty blockers as adding to the difficulty of consent, but in effect, the courts will now play a much greater role in decisions, which are already highly emotionally charged.
Speaking outside the Royal Courts of Justice, Ms Bell said she was "delighted" with the ruling.
"This judgment is not political, it's about protecting vulnerable children," she said.
"I'm delighted to see that common sense has prevailed."
Paul Conrathe, the solicitor for both claimants, said the ruling was "an historic judgment that protects children who suffer from gender dysphoria".
He said the judgment showed "that a culture of unreality has become embedded in the Tavistock".
"This may have led to hundreds of children receiving this experimental treatment without their properly informed consent," he said.
Lui Asquith, from trans children's charity Mermaids, said the ruling was a "devastating blow" and "a potential catastrophe for trans young people across the country".
The charity said: "We believe very strongly that every young person has the right to make their own decisions about their body and that should not differ because somebody is trans."
An NHS spokesperson said: "We welcome the clarity which the court's decision brings. The Tavistock have immediately suspended new referrals for puberty blockers and cross-sex hormones for the under-16s, which in future will only be permitted where a court specifically authorises it."
In September, the NHS announced an independent review into gender identity services for children and young people.
The Tavistock and Portman NHS Trust said it was "disappointed by today's judgment and we understand that the outcome is likely to cause anxiety for patients and their families".
It added: "Our first duty is to our patients, particularly those currently receiving hormone blocking treatment, and we are working with our partners, University College London Hospitals NHS Foundation Trust and Leeds Teaching Hospitals NHS Trust, to provide support for patients concerned about the impact on their care."
Its spokesman also confirmed the trust would seek permission to appeal against the judgment.
In a separate case, a 14-year-old transgender boy has begun legal action against NHS England over delays to gender reassignment treatment.