SACRAMENTO -- California is failing to provide adequate psychiatric treatment to mentally ill inmates on death row, a federal judge ruled Tuesday, though he is letting the state decide how to fix the problem.

U.S. District Judge Lawrence Karlton ordered state officials to work with a court-appointed monitor to find solutions. Options include creating a specialized inpatient psychiatric facility at San Quentin State Prison, which houses condemned inmates.

State officials are not meeting their constitutional duty to provide condemned inmates with sufficient inpatient treatment, the Sacramento-based judge said in a 28-page ruling.

"The state is committed to providing quality medical and mental health care for all inmates," Deborah Hoffman, a spokeswoman for the state Department of Corrections and Rehabilitation, said in a statement. She said the state will work with the court's special master to make sure that mentally ill inmates on death row receive proper care.

Michael Bien, an attorney who represents mentally ill inmates in the ongoing class-action lawsuit, called the ruling "a very significant victory."

Bien said the finding shows that state officials are violating the inmates' constitutional rights by failing to provide appropriate access to inpatient psychiatric care.

"I think the court acknowledged the complexity of the issue. ... You can't just plug them into the rest of the prison system," he said.

Inmates' attorneys would not object to creating a psychiatric unit at San Quentin to treat inmates awaiting execution, Bien said. That would keep the inmates close to their families and attorneys while saving the state the expense of building a high-security mental health unit at another prison, he said.

The ruling comes as part of an ongoing 23-year-old lawsuit that helped lead to sweeping changes in the state prison system, including a sharp reduction in overcrowding.

It's the latest ruling resulting from a series of hearings Karlton has held since April, when he rejected Gov. Jerry Brown's attempt to end court oversight of mental health programs.

He also is considering whether guards use too much force, including large amounts of pepper spray, on mentally ill inmates and whether prolonged solitary confinement violates the rights of mentally ill inmates.