A bill that would have allowed juvenile offenders sentenced to life without parole the chance to pursue freedom after a quarter-century in prison narrowly failed to pass the state Assembly Thursday.

In an hourlong floor debate, Republicans seemed to sway wavering Democrats by recounting details of vicious rapes and brutal killings.

Assemblyman Tim Donnelly, R-Hesperia, argued that the bill was about much more than “whether we’re going to give people a chance at redemption.” He said it’s about teens like Scott Dyleski, convicted of “slaughtering” his Lafayette neighbor in 2005, so he could steal her credit cards and buy marijuana. Right after the vicious crime, Donnelly noted, the 16-year-old had sex with his girlfriend.

Senate Bill 9 “is sending a signal we don’t actually value life,” Donnelly added. “If you take a life, then the least we can do is say you have to give up yours, whether it’s life in prison, or the death penalty.”

The bill by state Sen. Leland Yee, D-San Francisco, was backed by human rights advocates and child psychiatrists. It was approved by the full Senate and supported by all but a handful of key Assembly Democrats.

In a dramatic twist, although Yee counted 40 votes late in the day — one shy of passage — his failure to convince enough Democrats ultimately doomed the bill in a 36-36 vote, with eight members abstaining when the final roll was called.

The legislation would have brought California in line with every other country in the world and a growing number of states changing their sentencing laws to reflect greater consideration of an offender’s developmental stage when he or she commits a crime.

Yee, a child psychologist who has authored two similar bills, said he will have SB 9 considered one more time in the Assembly before the legislative session ends Sept. 9.

His bill would allow those who committed crimes at age 17 or younger to petition the court for a “resentencing” hearing. Judges could then reduce life-without-parole sentences to 25 years to life, with the possibility of appealing to parole boards.

But on Thursday, passionate Republicans argued that Yee’s bill broke a promise with the victims’ families that they were done with years of torturous court hearings. And in the rare cases where justice may not have been served, they contended, the governor could issue a pardon.

Assemblyman Donald Wagner, R-Irvine, noted under the bill, the juvenile killer of a California Highway Patrol officer on the Pomona courthouse steps in 2004 could one day “walk the streets again.” But, he said, a widow’s husband would never have that chance.

Assemblywoman Shannon Grove, R-Bakersfield, recounted the sexual crime of 17-year-old Samuel Puebla, describing how in 2003 he ripped off a 19-year-old San Jose college student’s clothes and hit her head so hard her eardrum burst before he killed her.

Aggregate data on the 295 juvenile offenders serving life without parole sentences, however, convinced supporters of SB 9 that there may be some inmates who deserve a chance at parole. According to a Human Rights Watch examination in 2007, 45 percent of the inmates had not actually committed murder, but were nearby in getaway cars, standing lookout, or had fled the scene after joining a robbery-turned-fatal in which someone else was the shooter. The study also found African-American juvenile offenders were 18 times more likely than whites to be serving sentences of life without parole. Latinos were five times more likely.

That was enough to persuade several Democrats who spoke on the Assembly floor.

“This is an easy vote,” said Steven Bradford, D-Inglewood. “It’s about redemption.”

Bradford noted that the nation was founded by people with such an opportunity. “Outside of Native Americans and slaves, everyone who came to this country came here for a second chance,” he said.

Under Yee’s bill, petitioners would have to behave well in prison and demonstrate remorse. And they would have to show evidence they had improved their lives behind bars through education, religion or a vocation.

Opening the heated debate Thursday, Assemblyman Gil Cedillo, D-Los Angeles, tried to fend off concerns that bill backers were starry-eyed liberals.

“We’re not talking about Boy Scouts or Girl Scouts,” he said. “We’re talking about people who in many instances have ended the lives of others. Let’s be clear: They are not children; they are young adults who must be accountable.”

He added, Yee’s bill simply addresses whether in a civilized society those who committed crimes before their brains were fully developed should have hope for eventual release.

“Justice without mercy is hollow,” Cedillo said. “It’s hollow for the victims and their families, and it’s hollow for all of us.”