SACRAMENTO, Calif. – The U.S. Supreme Court ruled Monday that California must drastically reduce its prison population to relieve severe overcrowding that has exposed inmates to increased violence, disease and death.

The decision, however, doesn’t mean the prison gates will swing open in an uncontrolled release.

The high court’s 5-4 decision calls on the state to cut the population to no more than 110,000 inmates. To get there, state officials have two years to either transfer some 33,000 inmates to other jails or release them.

California has already been preparing for the ruling, driven as much by persistent multibillion dollar budget deficits as by fears for the well-being of prison inmates and employees. The state has sent inmates to other states. It plans to transfer jurisdiction over others to counties, though the state doesn’t have the money to do it.

“They’ve made a lot of plans already,” said Michael Bien, one of the attorneys who sought the ruling on behalf of mentally and physically ill inmates who suffered in severely crowded conditions. “We’re sure it can be done safely and appropriately.

“What’s more, it will save a lot of money,” he said.

The ruling raised concerns among California lawmakers and attorneys general from 18 other states who argued that a decision ordering the reduction of California’s inmate population infringes on states’ rights and could leave their prisons open to similar lawsuits.

It’s “a historic attack on the constitutional rights of states and the liberty of all Californians,” said former state Sen. George Runner, who had intervened in the lawsuit on behalf of legislative Republicans. It will result in “flooding our neighborhoods with criminals.”

The ruling gives California two weeks to submit a population reduction plan and two years to comply.

However, Justice Anthony Kennedy, a California native who wrote the majority opinion, said the state could ask a federal court for more time to reach the 110,000-inmate target, even as he chastised California for allowing unconstitutional conditions to persist for years.

“Our goal is to not release inmates at all,” said Matthew Cate, the state corrections secretary. Shorter term inmates will leave prison before the Supreme Court’s deadline expires, and newly sentenced lower-level offenders would go to local jails under the plan.

Concerns over prison crowding and security grew over the weekend with a pair of riots that injured inmates, but no guards.

A fight by nearly 200 inmates in a San Quentin State Prison dining hall Sunday left four men with stab or slash wounds. On Friday, six inmates were sent to hospitals, two of them with serious injuries, after about 150 inmates rioted at California State Prison, Sacramento.

A special three-judge panel decided in 2009 to order the prison population reduction. Monday’s order puts them in charge of the state’s compliance.

Joined by the court’s four Democratic appointees, Kennedy wrote that the crowding reduction is “required by the Constitution” to correct violations of inmates’ rights that have persisted for years despite lower court rulings requiring improvements.

The growth in the prison population in the nation’s most populous state can be attributed in part to years of get-tough sentencing laws, including a three-strikes law that sends repeat offenders to prison for life. As of May 11, there were roughly 143,000 inmates in a 33 adult prison-system designed to hold 80,000.

At the peak of overcrowding in 2006, nearly 20,000 inmates were living in makeshift housing in gymnasiums and other common areas, often sleeping in bunks stacked three high. Prison doctors conducted examinations in shower stalls or in makeshift offices without running water, often in full view of other inmates.

One of the federal judges involved in the lower court ruling once blamed the prison system’s poor medical care for causing the death of about one inmate every week due to neglect or medical malpractice.

The same judge in 2006 seized control of the prison health care system, putting it under the management of a federal receiver.

A second judge in the case has blamed crowding for contributing to poor care for mentally ill inmates, leading some to kill themselves.

At the time, then-Gov. Arnold Schwarzenegger declared a public safety emergency because of the crowding. He then began shipping inmates to private prisons in Arizona, Mississippi and Oklahoma. More than 10,000 California inmates are now housed in private prisons out of state.

The ruling comes amid efforts in many states, accelerated by budget gaps, to send fewer people to prison in the first place. Proposals vary by state, but include ways to reduce sentences for lower-level offenders, direct some offenders to alternative sentencing programs and give judges more discretion in sentencing.

“There’s a growing consensus that there are better ways to run criminal justice systems,” said Michael Mushlin, an expert on prisoners’ rights at Pace Law School in White Plains, N.Y.