The U.S. Supreme Court ruled that California must remove tens of thousands of inmates from its prison rolls in the next two years, and state officials vowed to comply, saying they hoped to do so without setting any criminals free.

Administration officials expressed confidence that their plan to shift low-level offenders to county jails and other facilities, already approved by lawmakers, would ease the persistent crowding that the high court said Monday had caused "needless suffering and death" and amounted to cruel and unusual punishment.

Gov. Jerry Brown's transfer plan "would solve quite a bit" of the overcrowding problem, though not as quickly as the court wants, said Matthew Cate, secretary of California's Department of Corrections and Rehabilitation. "Our goal is to not release inmates at all.''

But the governor's plan would cost hundreds of millions of dollars, to be paid for with tax hikes that could prove politically impossible to implement. And at present, Brown's plan is the only one on the table.

The governor issued a muted statement calling for enactment of his program and promising, "I will take all steps necessary to protect public safety."

The court gave the state two years to shrink the number of prisoners by more than 33,000 and two weeks to submit a schedule for achieving that goal. The state now has 143,335 inmates, according to Cate.

Monday's 5-4 ruling, upholding one of the largest such orders in the nation's history, came with vivid descriptions of indecent care from the majority and outraged warnings of a "grim roster of victims" from some in the minority.

In presenting the decision, Justice Anthony M. Kennedy, a Sacramento native, spoke from the bench about suicidal prisoners being held in "telephone booth-sized cages without toilets" and others, sick with cancer or in severe pain, who died before being seen by a doctor. As many as 200 prisoners may live in a gymnasium, and as many as 54 may share a single toilet, he said.

Kennedy, whose opinion was joined by his four liberal colleagues, said the state's prisons were built to hold 80,000 inmates, but were crowded with as many 156,000 a few years ago.

He cited a former Texas prison director who toured California lockups and described the conditions as "appalling," "inhumane" and unlike any he had seen "in more than 35 years of prison work."

The court's four conservatives accused their colleagues of "gambling with the safety of the people of California," in the words of Justice Samuel A. Alito Jr. "I fear that today's decision will lead to a grim roster of victims. I hope that I am wrong. In a few years, we will see," he said.

Justice Antonin Scalia, delivering his own dissent in the courtroom, said the majority had affirmed "what is perhaps the most radical injunction issued by a court in our nation's history." He added, "terrible things are sure to happen as a consequence of this outrageous order." Chief Justice John G. Roberts Jr. and Justice Clarence Thomas also dissented.

Law enforcement officials in California concurred and said that trying to squeeze more inmates into already overcrowded county systems would force some early releases.

"Citizens will pay a real price as crime victims, as thousands of convicted felons will be on the streets with minimal supervision," Los Angeles County Dist. Atty. Steve Cooley said in a statement. "Many of these 'early release' prisoners will commit crimes which would never have occurred had they remained in custody."

"It's an undue burden …to deal with the state's problems,'' said Jerry Gutierrez, chief deputy of the Riverside County Sheriff's Department.

Republican lawmakers said they would continue to fight the governor's plan and its reliance on tax increases. Democrats "are looking for any excuse they can to try to have more taxes," said the leader of the state Senate's GOP minority, Bob Dutton of Rancho Cucamonga.

Dutton said state officials should instead fast-track construction of new prisons and pressure the federal government to take custody of thousands of illegal immigrant felons housed in the state system.

Administration officials said their plan would keep the public safe by moving offenders into county lockups, drug treatment programs and other types of criminal supervision. But Cate said the Brown administration "cannot act alone" and conceded that release of some prisoners remains a possibility.

He urged the Legislature to immediately fund Brown's $302-million plan, which would shift 32,500 inmates to county jurisdiction by mid-2013. Among those identified for the program are tens of thousands of parole violators sent to costly state prisons every year to serve 90 days or less.