A California man has been sentenced to up to eight years in prison for stealing a $3.99 (£2.60) bag of shredded cheese in a case critics say shows the need for reform of the state's criminal justice system and the overcrowded state of its prisons.

Robert Ferguson, who prosecutors say has a nearly 30-year record of convictions for burglary and other offences, avoided a life sentence under the state's controversial "three strikes" law after a psychological evaluation deemed him bipolar and unable to control his impulses to steal, the Sacramento Bee reported.

Prosecutor Clinton Parish said Ferguson had spent 22 of the past 27 years behind bars but had failed to show he could obey the law. A judge sentenced him to seven years and eight months in prison, but he could be eligible for parole in three years.

The ruling came amid critical overcrowding in the California prison system, to which years of tough policies, the "war on drugs" and one of the highest US recidivism rates have contributed. The system held 166,569 inmates in August, but remains so overcrowded nearly 8,000 have been sent to prisons outside the state.

The state's three strikes law, passed in 1994, significantly increased the amount of time repeat convicted criminals serve in prison. It provides 25 years to life in prison for a third felony conviction by an offender with two or more prior serious or violent criminal convictions. As of March 2008, more than 41,000 people were in prison under the three strikes law. A 2005 legislative report estimated the law, including its application to nonviolent offences, added about $0.5bn in costs annually.

With prisoners stacked three-high in bunk beds in gymnasiums and packed into hallways and classrooms, California's prison system is so overcrowded that a series of judges have ruled conditions violate the US constitution's prohibition of cruel and unusual punishment. Last month, a federal judge ordered the state to reduce overcrowding by 55,000, the same week that a state court approved a life sentence for a man convicted of possessing 0.03 grams of methamphetamine.

America's most populous state has been crippled by political discord, unable to close a $20bn budget gap. Governor Arnold Schwarzenegger has called for a 12% cut in the state's prison budget, to $8.1bn.