WASHINGTON — The Supreme Court on Monday ruled that juveniles who commit crimes in which no one is killed may not be sentenced to life in prison without the possibility of parole.

Five justices, in an opinion by Justice Anthony M. Kennedy, agreed that the Eighth Amendment’s ban on cruel and unusual punishment forbids such sentences as a categorical matter.

“A state need not guarantee the offender eventual release,” Justice Kennedy wrote, “but if it imposes the sentence of life, it must provide him or her with some realistic opportunity to obtain release before the end of that term.”

The ruling marked the first time that the court excluded an entire class of offenders from a given form of punishment outside the context of the death penalty. “ ‘Death is different’ no longer,” Justice Clarence Thomas wrote in dissent.