Justice Anthony Kennedy joined the four-member liberal bloc to form the majority. The court's remaining four conservatives dissented.
Justice Elena Kagan wrote the majority opinion, saying Supreme Court precedent "and our individualized sentencing decisions make clear that a judge or jury must have the opportunity to consider mitigating circumstances before imposing the harshest possible penalty for juveniles."
Kagan said by requiring that all children convicted of homicide "receive lifetime incarceration without possibility of parole, regardless of their age and age-related characteristics and the nature of their crimes, the mandatory sentencing schemes ... violate this principle of proportionality, and so the Eighth Amendment's ban on cruel and unusual punishment."
Chief Justice John Roberts led the dissenters.
"Determining the appropriate sentence for a teenager convicted of murder presents grave and challenging questions of morality and social policy," Roberts wrote. "Our role, however, is to apply the law, not to answer such questions. The pertinent law here is the Eighth Amendment to the Constitution, which prohibits 'cruel and unusual punishments.' Today, the court [majority] invokes that amendment to ban a punishment that the court does not itself characterize as unusual, and that could not plausibly be described as such."
Twenty-nine states impose life without parole on some of those who killed as teenagers.
Nearly 2,500 prisoners across the country are serving life sentences without the possibility of parole for murders they committed before the age of 18.
One of the cases that brought the ruling involves a 14-year-old who beat a man with a baseball bat, robbed him and left him to burn to death in a trailer nearly 10 years ago in Lawrence County, Ala. The defendant was 14 at the time.
The other case involved an Arkansas defendant who also was sentenced to life without parole for a homicide committed at age 14. But in that case, the teenager did not do the killing but participated in a robbery that ended in a killing by someone else.
The Supreme Court majority reversed lower court rulings supporting the sentences.
Interpol investigating stolen passports on missing flight
Jessica Simpson shares three-way kiss with friends in photo