Natasha Abrahart was found dead on the day she was due to take part in a group presentation in a 329-seat lecture theatre at the University of Bristol.
The 20-year-old's parents took action over the university's failure to make adjustments for her social anxiety disorder.
The university said it might appeal.
Judge Alex Ralton, who heard the case at Bristol County Court, said: "In my judgement there can be no doubt that there was direct discrimination, especially once the university knew or should have known that a mental health disability of some sort was preventing Natasha from performing."
In a 46-page written judgement, he found the university had breached its duties to make reasonable adjustments to the way it assessed Miss Abrahart and treated her unfavourably because of the consequences of her disability.
He found these breaches led to the physics student's death, noting that "it was accepted by the medical experts that the primary stressor and cause of Natasha's depressive illness was oral assessment".
He listed occasions when Miss Abrahart, who was described as "hard-working and high-achieving", was given a succession of poor marks - including 0 out of 100 - for failing to attend lab interviews or answering questions at oral assessments poorly.
"Her poor performance would likely have been down to being unable to orally answer questions," he said.
Miss Abrahart had made a previous suicide attempt in the winter term before her death in April, and university staff were aware she was struggling.
Before the presentation, known as a laboratory conference, Miss Abrahart had struggled to complete one-on-one interview-based assessments, attending only two out of five.
The court heard in February 2018 she emailed one university employee, saying: "I've been having suicidal thoughts and to a certain degree attempted it."
An inquest into Miss Abrahart's death in May 2019 found she had been neglected by mental health services but the coroner ruled the adequacy of support provided by the university was outside of the inquest's scope.
Speaking after the ruling, Miss Abrahart's father Robert, a retired university lecturer from West Bridgford, Nottinghamshire, said: "Today, 1,481 days after Natasha took her own life on the day of an assessment she simply couldn't do, after years of protestations from the university that it did all it could to support her, after having battled our way through an inquest and a civil trial, we finally have the truth.
"The University of Bristol broke the law and exposed our daughter to months of wholly unnecessary psychological trauma, as she watched her grades plummet, and her hopes for the future crumble before her eyes."
Her mother Margaret added: "We really hope the University of Bristol will finally take its head out of the sand and recognise that now is the time for change.
"We hope they will apologise for the role they played in Natasha's death and will take us up on our offer of help."
A University of Bristol spokesperson said: "Our whole university community has been deeply affected by Natasha's tragic death and we would once again like to extend our sympathies to her friends and family.
"We believe staff in the School of Physics worked incredibly hard and diligently to support Natasha during her time with us, and it was due to their efforts that she was receiving specialist mental health support from the NHS.
"Our staff's efforts also included offering alternative options for Natasha's assessments to alleviate the anxiety she faced about presenting her laboratory findings to her peers. We are very grateful to them for their endeavours on Natasha's behalf and for their unwavering commitment to our students.
"Given the significant impact this decision could have on how all higher education providers support their students, we are reviewing the decision carefully, including whether to appeal."