HARTFORD, Conn. — Connecticut’s highest court on Thursday ordered the state’s death row emptied out, ruling that the 2012 law abolishing capital punishment for any future crimes must be applied to the 11 men facing execution for offenses they committed before the measure took effect.

In a sharply divided 4-3 ruling, the court declared the death penalty violates the state’s constitution, “no longer comports with contemporary standards of decency and no longer serves any legitimate penological purpose.”

“This is a strong decision and I think it’s going to be very helpful nationally,” said Michael Courtney, who heads the capital defense unit for Connecticut’s Office of the Public Defender. “The United States Supreme Court may consider these very issues under the federal Constitution in the fall.”

The court’s ruling cited factors that have come up in other states to abolish the death penalty, including racial and economic disparities in its use, the costs involved with appeals, the cruelty of the wait for execution and the risk of executing innocent people.

“They went at this from multiple angles in a way that is going to provide ammunition for abolitionists across the country,” said David McGuire, an attorney with the American Civil Liberties Union of Connecticut.

Opposition to the death penalty has been growing in the United States. Thirty-one states still have capital punishment, but several others have turned against it in recent years, including Nebraska, which voted for abolition in May, and Maryland, which abolished it in 2013. Robert Dunham, executive director of the nonprofit Death Penalty Information Center, noted that the number of death sentences imposed last year marked a 40-year low in the country.

The ruling comes in an appeal from Eduardo Santiago, whose attorneys successfully argued that any execution carried out after the 2012 repeal would constitute cruel and unusual punishment. Santiago, whose first death sentence was overturned, faced a second penalty hearing and the possibility of lethal injection for a 2000 murder-for-hire killing in West Hartford.

But the Connecticut ban had been passed prospectively because many lawmakers refused to vote for a bill that would spare the death penalty for Joshua Komisarjevsky and Steven Hayes. They had been convicted of killing a mother and her two daughters in a highly publicized 2007 home invasion in Cheshire.

Jennifer Hawke-Petit was raped and strangled. Her daughters, Hayley, 17, and Michaela, 11, died of smoke inhalation after they were doused with gasoline and the house was set on fire. Michaela was sexually assaulted.

In his ruling, Palmer wrote that it would not be permissible to execute other convicts “merely to achieve the politically popular end of killing two especially notorious inmates.”

The ruling drew harsh criticism from the three dissenting justices and legislative Republicans, who accused the court of taking on the role of policymakers.

“In making this determination, the majority disregards the obvious: the Legislature, which represents the people of the state and is the best indicator of contemporary societal mores, expressly retained the death penalty for crimes committed before the effective date of (the repeal),” wrote Chief Justice Chase Rogers.

Santiago was sentenced to lethal injection in 2005 for the killing of 45-year-old Joseph Niwinski, who prosecutors say was shot in exchange for a pink-striped snowmobile with a broken clutch in 2000.

But the state Supreme Court overturned the death sentence and ordered a new penalty phase in 2012, saying the trial judge wrongly withheld key evidence from the jury regarding the severe abuse Santiago suffered while growing up.

Santiago’s mother expressed joy Thursday that her son no longer had to fear execution.

“It’s a big weight lifted off everyone,” Christina Hagarty said. “Good things come to those who wait.”

The chief state’s attorney’s office declined to comment on the ruling Thursday morning, saying it was still reviewing the decision.

Senior Assistant State’s Attorney Harry Weller had argued that there were no constitutional problems with the new law and that death row inmates simply faced a penalty under the statute that was in effect when they were convicted.

Connecticut has had just one execution since 1960. Serial killer Michael Ross was put to death in 2005 after winning a legal fight to end his appeals.

Democratic Gov. Dannel P. Malloy issued a statement Thursday saying those who have been on death row will spend the rest of their lives in state prisons with no possibility of freedom.

“Today is a somber day where our focus should not be on the 11 men sitting on death row, but with their victims and those surviving family members,” he said. “My thoughts and prayers are with them during what must be a difficult day.”