Illinois has reached an inter-agency agreement that will allow some of the state’s most severely mentally ill inmates to be treated in an inpatient facility within the Elgin Mental Health Center.

But the agreement, reached Wednesday night as part of a settlement, means the facility may have to transfer some non-incarcerated patients to two state-run mental health hospitals in Chicago and the south suburbs.

Under the agreement between the state’s Human Services and Corrections departments, 44 beds at the Elgin facility will be used for inpatient treatment for inmates with serious mental illness.

Those inmates — 22 female and 22 male — will be transferred from state correctional centers to the Elgin facility, where they will be stabilized and ultimately sent back to their respective prisons, according to Gov. Bruce Rauner’s administration. In some cases they may be transferred to lesser security prisons based on their stabilization and health.

Currently the hospital in part takes in “forensic” patients – inmates who have been deemed unfit to serve trial, or those who have been admitted involuntarily. But it also has “civil beds” — intended for members of the public without health insurance or those sent to the facility from hospitals or emergency rooms to be stabilized.

The Department of Corrections will take over two units — one civil unit that usually has about 20 to 25 female patients, and one forensic unit with 20-25 male patients.

Rauner’s administration on Friday said that civil patients do not stay at the facility long-term. Nevertheless, room would be made at hospitals to make sure those patients are treated, the administration said.

Civil patients are expected to be transferred to two other mental health hospitals, Chicago-Read Mental Health Center and Madden Mental Health Center in Hines.

The state runs three inpatient centers in the Chicago area for the mentally ill, including the Elgin facility. But it also runs facilities in Springfield and southern Illinois.

Mental health care in Chicago is already limited. The closure in 2012 of six city-run mental health clinics sent many mentally ill patients to the Cook County Jail, critics say. The state also closed the Tinley Park Medical Health Center in the south suburbs and the Singer Mental Health Center in Rockford in 2012.

The agreement is part of the state’s settlement over a federal lawsuit filed by Ashoor Rasho in 2007. Rasho, who suffered from mental illness, sued the state over his treatment at Pontiac Correctional Center where he said he was placed in solitary confinement, which worsened his condition. The suit also claimed that mentally ill inmates were forcibly given injections of medicines to sedate them.

A settlement was approved in May and included provisions for the state to make changes to its policies, including limiting an inmate’s time separated from the general prison population. It also included a provision that a mental health professional be consulted on disciplinary terms for mentally ill patients.

Also part of the settlement is the renovation and conversion of the Illinois Youth Center in Joliet into a treatment facility for mentally ill inmates.