WASHINGTON – The Supreme Court ruled Wednesday that even sex offenders deserve to have the reasons for their sentences determined by a jury, not a judge.

The justices ruled 5-4 that a federal law requiring sex offenders to return to prison based on a judge's new findings is unconstitutional. Supreme Court precedent gives juries, not judges, the power to determine criminal conduct.

Associate Justice Neil Gorsuch, one of President Donald Trump's two nominees on the court, wrote the opinion and was joined by the court's four liberal justices – for the fourth time this term.

"A jury must find every fact that is essential to an individual's punishment," Gorsuch said. In the case before the court, the accused received "a new prison term based instead only on facts found by a judge by a mere preponderance of the evidence."

It was a victory for Andre Hammond, an Oklahoma man sentenced in 2010 to more than three years in prison on child pornography charges. In 2015, a judge found him guilty of violating his supervised release and tacked on five more years in prison.

The question before the justices: Can a judge, rather than a jury, decide what facts merit a new sentence?

Four conservative justices said yes. In their dissent, Justice Samuel Alito accused the decision by Gorsuch and his liberal allies of "laying the groundwork for later decisions of much broader scope" and "revolutionary implications."

"It represents one particular view about crime and punishment that is ascendant in some quarters today but is not required by the Constitution," Alito wrote. "If the court eventually takes the trip that this opinion proposes, the consequences will be far-reaching and unfortunate."

More:Supreme Court's top cases of 2019

It was the second decision in a week involving the Sex Offender Registration and Notification Act, a 2006 law requiring sex offenders to register and notify authorities when they move.

Last week, the court ruled 5-3 that the law properly gives the attorney general latitude in applying it to about 500,000 prior offenders. Challengers had argued only Congress can make that decision.

That ruling could be short-lived. The fifth vote was provided by Alito, who disagreed with his liberal colleagues on their reasoning and indicated he would be willing to strike down Congress' power to delegate that authority in a future case.