A federal judge in Montgomery today ruled in favor of groups who say Alabama provides constitutionally inadequate mental-health care for inmates in its prisons.

"After a lengthy trial, this claim is now before the court for resolution on the merits. Upon consideration of the evidence and arguments, the court finds for the plaintiffs in substantial part," U.S. District Court Judge Myron Thompson stated in his 302-page ruling.

The plaintiffs in this phase of this class-action lawsuit are a group of seriously mentally ill state prisoners and the Alabama Disabilities Advocacy Program (ADAP), which represents mentally ill prisoners in Alabama.

The defendants are the Commissioner of the ADOC, Jefferson Dunn, and the Associate Commissioner of Health Services, Ruth Naglich, who are sued only in their official capacities.

The ruling stated, "Surprisingly, the evidence from both sides (including testimony from Commissioner Dunn and Associate Commissioner Naglich as well as that of all experts) extensively and materially supported the plaintiffs' claim."

Thompson ordered that the court and all the parties are to meet and discuss a remedy. "The court emphasizes that given the severity and urgency of the need for mental-health care explained in this opinion, the proposed relief must be both immediate and long term. No partial final judgment shall issue at this time as to the claim resolved in this entry," he wrote.

According to the ruling, approximately 3,400 inmates receive some sort of mental health care in state prisons. Of the 15 major Alabama Department of Corrections facilities, three are considered treatment hubs for mentally ill inmates-- meaning those locations include mental health units.

Thompson concluded a non-jury trial on the mental health claims in February, but only today ruled that the care does not meet constitutional standards.

"Even when identified, mentally ill prisoners receive significantly inadequate care... ADOC does not provide hospital-level care for those who need it," Tuesday's ruling stated.

Bill Van Der Pol, a senior staff attorney for ADAP, said evidence presented during the trial showed that the DOC's procedure for administering involuntary mental health medication was unconstitutional. He said approximately 40- to 60 inmates are involuntarily medicated at any given time.

Jamie Wallace (Alabama Department of Corrections via AP)

Dunn said during testimony in January that the ability to provide mental health care in prisons is affected by overcrowding and a short staff.

The court has not yet set a date for the final phase of the case, which challenges medical and dental care in the ADOC.

Bob Horton, Public Informations Manager for the DOC, released a statement today. "In 2014, the Southern Poverty Law Center and the ADAP instituted this case, challenging various aspects of the ADOC system... Throughout the course of this case, Commissioner Jeff Dunn has repeatedly affirmed the Department's commitment to the provision of necessary mental health services to inmates in the custody of the Department of Corrections. Nothing about this opinion will alter this commitment," it stated. "Commissioner Dunn and his staff are reviewing the court's lengthy opinion with legal counsel to determine the next steps his department will take in the case."

Included in the statement was a comment from Dunn. It stated, "This order will require a broader conversation with our state leadership about how we can responsibly address the challenges facing the department. While portions of the trial focused upon issues related to mental health care, it also highlighted many of the other challenges facing the department like our outdated facilities and our long-standing needs in the area of security. We look forward to having an open and frank conversation with our state leadership about how to make meaningful investments into our department to ensure the safety of our staff, the security of our facilities and the well-being of those in our care."

"This ruling means that prisoners with mental illness may finally get the treatment they have been denied for so long," said Maria Morris, Southern Poverty Law Center senior supervising attorney. "The suffering some of these men and women have endured is excruciating and inhumane. We are pleased Judge Thompson has demanded that the state of Alabama meet its constitutional obligation to provide adequate care."

A statement from the SPLC read in part, "The ADOC, it became clear, is fatally slow to respond to suicidal thoughts among prisoners and keen on saving money whenever it can. Incarcerated witnesses told the judge about horrific conditions, especially in the spaces designated for mental health treatment."

Thompson's ruling also cited the case of a prisoner, who testified last year on the lack of treatment in prisons. "The case of Jamie Wallace is powerful evidence of the real, concrete and terribly permanent harms that woefully inadequate mental-health care inflicts on mentally ill prisoners in Alabama."

Just weeks after his testimony, Wallace was found hanging in his cell.

Lisa Borden, a Birmingham attorney who represented the prisoners, said: "The court's opinion today confirmed, and condemned, the constitutionally inadequate conditions that prisoners with serious mental illness have suffered for so long. ADOC's system of mental health care fails the moment a prisoner walks in the door, and continues to fail at every step. As the court found, these failures to provide desperately needed treatment subject prisoners to needless pain, serious injury, and even, in cases like that of Jamie Wallace, death. In addition, the court's opinion confirms that ADOC officials have long been aware of these failures, but have done little or nothing to correct them. We are gratified that ADOC officials will no longer be permitted to sit on their hands or pass the buck at the risk of people's lives."

Gov. Kay Ivey also issued a statement: "There are obviously several issues within our prison system that must be addressed. Over the next few weeks Commissioner Dunn, his staff, and my office will be reviewing Judge Thompson's order," she stated.

"I am committed to providing justice to all Alabamians by ensuring constitutionally-permissible conditions for all prisoners...All appropriate options at my disposal, including the possibility of a special session, will be considered as potential remedies to address the judge's order."

AL.com's Kent Faulk contributed to this report