PITTSBURGH — The Pennsylvania Department of Corrections has settled a lawsuit by agreeing to keep mentally ill inmates from being locked in solitary confinement and to improve their care, a spokeswoman said on Tuesday.

State prisons, under terms of the settlement, have hired added security and health professionals to ensure that mentally ill inmates spend at least 20 hours a day outside their cells, Susan McNaughton, a Department of Corrections spokeswoman, said.

The lawsuit filed in 2013 by the Disability Rights Network of Pennsylvania, a nonprofit advocacy group, accused the state of violating the constitutional rights of mentally ill inmates at 26 state correctional facilities, keeping them in solitary confinement without access to treatment.

The Department of Corrections did not admit to the rights violations but is revising many of its policies as result of the civil suit, McNaughton said. The settlement was reached on Monday but not announced until Tuesday.

“We have 4,000 mentally ill inmates, and the number of mentally ill inmates is rising,” she said. “We are looking forward to partnership with the Disability Rights Network and to ensuring we are doing the right thing.”

Previously, she said, mentally ill inmates who committed infractions could be subject to the same punishments as non-mentally ill inmates, including 23 hours of isolation per day.

The Disability Rights Network argued such isolation exacerbated mental health problems and at times led to self-harm or suicide.

Prison staff members are being trained to differentiate between mental health and behavioral problems, McNaughton said.

Robert Meek, lead lawyer for the Disability Rights Network, said similar settlements have been reached in New York, Massachusetts and Arizona.

“We are in a small group of states that have come around to the point of view that solitary confinement is harmful to the mentally ill,” he said.

Meek said Pennsylvania’s Department of Corrections would be monitored for compliance and that inmates that have been in solitary confinement for longer than a year would undergo mental health evaluations regardless of their previous conditions.