Two people with mental health problems have won a legal challenge against the government tests for sickness benefit.
Judges at the Upper Tribunal ruled the Work Capability Assessment puts people with mental illness, autism and learning difficulties at a substantial disadvantage.
The process is too difficult for many to navigate, a court heard.
The Department for Work and Pensions says there are safeguards in place and it will appeal against the ruling.
Work Capability Assessment (WCA) tests, which measure a person's entitlement to Employment and Support Allowance (ESA) by determining whether they are fit for employment, were introduced in 2008 and are carried out on behalf of the government.
The claimants alleged the system discriminated against them but the judges have asked to see further evidence before it can make a decision on this.
The court was told people who have conditions that mean they lack insight can struggle to gather the right documents needed for a successful claim, such as doctors' reports.
The judgment was the result of a judicial review brought by two claimants with mental health problems, whose identities have been protected.
Lawyers for the two argued that where a claim is from someone with a mental health problem, it should be the government's responsibility to seek additional medical evidence.
UK charities Rethink Mental Illness, Mind and the National Autistic Society intervened in the case to provide evidence based on the experiences of their members and supporters.
Almost 20,000 people are assessed each week for ESA - including those moving over from the old benefit system of Incapacity Benefit (IB) - in England, Wales and Scotland, DWP figures show. The benefits system in Northern Ireland is administered separately.
More than a third of these people are claiming primarily for mental health problems, meaning tens of thousands of people each month are going through a process that puts them at a substantial disadvantage, the mental health charity said.
Under the current system, evidence from a professional, such as a GP or social worker, is expected to be provided by claimants themselves. There is no obligation for the DWP to collect this evidence, even on behalf of the most vulnerable claimants - apart from in some rare cases.
The charities involved in the case called on the government to suspend use of WCA tests for the people they help.
Mind's chief executive Paul Farmer said: "The judgment is a victory, not only for the two individuals involved in this case, but for thousands of people who have experienced additional distress and anxiety because they have struggled through an assessment process which does not adequately consider the needs of people with mental health problems."
The DWP said it wished to work with charities to "continually improve" the WCA for people with mental health problems.
But a spokesperson said: "We disagree with today's ruling and intend to appeal.
"We believe we have made - and continue to make - significant improvements to the WCA process for people with mental health conditions. The percentage of people with mental health conditions who go into the support group for ESA has more than tripled since 2010.
The DWP said the tribunal had made clear that there are safeguards built in to the WCA process to help ESA claimants.