A B.C. Supreme Court judge has ruled that the practice of indefinite solitary confinement in Canadian prisons will end, after deeming the practice unconstitutional.

The ruling released Wednesday was based off a nine-week trial between the B.C. Civil Liberties Association and the John Howard Society of Canada verse the Attorney General of Canada.

“This is the most significant prison law decision from a trial court in Canadian history,” Jay Aubrey, staff lawyer at the BCCLA, said in a news release.

“It is a stunning decision that is grounded in four decades of history, and the best social science and medical evidence on the impact on inmates health of solitary confinement, and alternatives to solitary confinement.”

Justice Peter Leask says the practice of isolating prisoners for undefined lengths of time is unconstitutional, but he suspended his decision for 12 months to give the government time to deal with its ramifications.

The Crown argued the practice is a reasonable and necessary tool when prisoners pose a threat to others or are at risk of being harmed by the general prison population.

The federal government introduced a bill in June that would set an initial time limit for segregation of 21 days, with a reduction to 15 days once the legislation is law for 18 months.

The government tried to stop the trial, saying the legislation introduced last year would impose a time limit on solitary confinement terms, but the judge allowed the case to proceed.

Leask concluded in his judgment released Wednesday that prolonged confinement places the federal inmates in significant risk of serious psychological harm, including mental pain and suffering, and puts them at increased risk of self-harm and suicide.

The written decision says the risk of harm is intensified in the case of inmates with mentally illness.

Leask wrote that while many acute symptoms are likely to subside when prisoners are brought out of segregation, “many inmates are likely to suffer permanent harm as a result of their confinement.”

Public Safety Minister Ralph Goodale said reform will take time and effort but the federal government has been working since early 2016 to correct the mistaken views and directions of the previous administration under former prime minister Stephen Harper.

“Our government is committed to addressing the needs of the most vulnerable in the federal correctional system,” Goodale said. He added that the government is reviewing the ruling but did not say whether it intends to file an appeal.

Aubrey said for inmates who have gone through solitary confinement, the decision means: “What’s been done to you is very, very wrong.”

Leask’s decision says the health of people can be put at risk after only a few days in segregation, and the risk of harm increases the longer someone is confined under those conditions.

The indeterminate length of administrative segregation is especially problematic because it “exacerbates its painfulness, increases frustration and intensifies the depression and hopelessness that is often generated in the restrictive environments that characterize segregation,” the decision says.

Josh Paterson, the association’s executive director, described the conditions of segregation as similar to “modern-day dungeons,” with evidence of walls covered in food and bodily fluids, people sleeping with their heads inches from toilets and screaming from other prisoners.

Often the only interaction for a prisoner is through a feed hole, Paterson added.