The Supreme Court ruled Monday that people serving life terms for murders they committed as teenagers must have a chance to seek their freedom.

The justices voted 6-3 to extend a ruling from 2012 that struck down automatic life terms with no chance of parole for teenage killers. Now, even those who were convicted long ago must be considered for parole or given a new sentence.

The court ruled in the case of Henry Montgomery, who has been in prison more than 50 years, since he killed a sheriff’s deputy as a 17-year-old in Baton Rouge, Louisiana, in 1963.

Justice Anthony Kennedy, writing the majority opinion, said that “prisoners like Montgomery must be given the opportunity to show their crime did not reflect irreparable corruption; and if it did not, their hope for some years of life outside prison walls must be restored.”

Kennedy said states do not have to go so far as to resentence people serving life terms. Instead, the states can offer parole hearings with no guarantee of release,

The decision does not expressly foreclose judges from sentencing teenagers to a lifetime in prison. But the Supreme Court has previously said such sentences should be rare, and only for the most heinous crimes.

In dissent, Justice Antonin Scalia said the ruling “is just a devious way of eliminating life without parole for juvenile offenders.” Justices Samuel Alito and Clarence Thomas joined Scalia’s dissent.

In the 5-4 decision in 2012, Justice Elena Kagan wrote for the majority that judges weighing prison terms for young offenders must take into account “the mitigating qualities of youth,” among them immaturity and the failure to understand fully the consequences of their actions.Three years ago, the justices struck down automatic life sentences with no chance of release for teenage killers, but did not answer then whether the ruling in Miller v. Alabama should be extended retroactively to Montgomery and hundreds of other inmates whose convictions are final.

Through legislative action or court rulings, 18 states have allowed inmates like Montgomery to be given new prison sentences or to ask for their release, according to The Sentencing Project. Louisiana is among seven states that had declined to apply the Supreme Court ruling retroactively.

Missouri courts have split on whether or not previously sentenced inmates who were under 18 at the time of the crime should get new sentencing hearings. The Court of Appeals Southern District held in October 2014 that sentencing was final. But the Western District last January declined to follow the Southern District’s ruling and held that Miller applies retroactively.

Both cases are now among several pending in the Missouri Supreme Court, which has been waiting for the U.S. Supreme Court to resolve the matter.

The Missouri Legislature has also struggled with the issue. Under state law, the only penalties for first-degree murder are the death penalty and life without parole, neither of which can be applied to defendants who were juveniles at the time of the crime.

Lawmakers this year have introduced bills taking different approaches to the problem. Most set lengthy sentences for defendants, with a chance at parole coming after as much as 40 or 50 years. Some versions wouldn’t apply to defendants whose cases are final for purposes of appeal. However, a House committee on Wednesday is set to hear a bill that would allow for parole hearings and to petition the courts to review their sentences.

The case is Montgomery v. Louisiana, 14-280. Wednesday’s bill is HB 1995.

Photo:Jessica Archer of Austin, Texas, center, watches as her husband Richard Archer flips their daughter Annie Archer, 5, in the air, as they wait in line to enter the Supreme Court on Oct. 13. The court was discussing sentences for young prison “lifers.” AP photo by Jacquelyn Martin