California's prison system will have two more years to comply with orders to ease overcrowding. Rich Pedroncelli / AP

Federal judges on Monday gave California two more years to meet a court-ordered prison population cap, the latest step in a long-running lawsuit aimed at improving inmate medical care.

In doing so, the judges said they would appoint a compliance officer who will release inmates early if the state fails to meet interim benchmarks or the final goal.

The judges said the delays have cost taxpayers money while causing inmates to needlessly suffer. Judges had previously extended the deadline in December.

The order from the three-judge panel delayed an April deadline to reduce the prison population to about 112,000 inmates. California remains more than 5,000 inmates over a limit set by the courts, even though the state has built more prison space and used some private cells.

"It is even more important now for defendants to take effective action that will provide a long-term solution to prison overcrowding, as, without further action, the prison population is projected to continue to increase and health conditions are likely to continue to worsen," the judges said in a five-page opinion scolding the state for more than four years of delay.

In its latest ruling, the special panel of judges tasked with considering the legal battle involving overcrowding said the state has continually failed to implement any of the measures approved by the panel and the Supreme Court that would have safely reduced the prison population and alleviated unconstitutional conditions involving medical and mental health care.

However, immediately enforcing the population cap would simply prompt the state to move thousands more inmates to private prisons in other states without solving the long-term crowding problem, the judges said.

Given that choice, they adopted a proposal outlined by Gov. Jerry Brown's administration that it can reach the population cap by the end of February 2016 through steps that include expanding a Stockton medical facility to house about 1,100 mentally ill inmates and freeing more than 2,000 inmates who are elderly, medically incapacitated, or who become eligible for parole because of accelerated good-time credits.

The judges said the state also has agreed to consider more population-reduction reforms over the next two years, including the possible establishment of a commission to recommend reforms of penal and sentencing laws.