The California prison system must reduce overcrowding by as many as 55,000 inmates within three years to provide a constitutional level of medical and mental health care, a federal three-judge panel tentatively ruled Monday.

Relying on expert testimony, the court ruled that the California prison system, the nation’s largest with more than 150,000 inmates, could reduce its population by shortening sentences, diverting nonviolent felons to county programs, giving inmates good behavior credits toward early release, and reforming parole, which they said would have no adverse impact on public safety. The panel said that without such a plan, conditions would continue to deteriorate and inmates might regularly die of suicide or lack of proper care.

“The evidence is compelling that there is no relief other than a prisoner-release order that will remedy the unconstitutional prison conditions,” the panel said in its tentative ruling.

The California attorney general, Jerry Brown, vowed to appeal the ruling.

“This order, the latest intrusion by the federal judiciary into California’s prison system, is a blunt instrument that does not recognize the imperatives of public safety, nor the challenges of incarcerating criminals, many of whom are deeply disturbed,” Mr. Brown said in a statement.