By SAM HANANEL

WASHINGTON — Prison reform advocates who have spent years campaigning against solitary confinement are counting on a powerful new ally in their quest to end the practice: Supreme Court Justice Anthony Kennedy.

Earlier this summer, Kennedy took the unusual step of condemning long-term solitary confinement, writing a separate opinion in a California death penalty case that had nothing to do with the issue.

It wasn’t the first time Kennedy had spoken out on the topic. He testified before Congress in March that American prisons rely too much on holding inmates in isolation and said it “literally drives men mad.”

But the tone of his June 18 opinion surprised many civil liberties groups with its almost explicit call for a fresh legal challenge to the practice of keeping prisoners in “a windowless cell no larger than a typical parking spot for 23 hours a day.”

“I’ve never seen it happen before,” said Amy Fettig, an attorney with the American Civil Liberties Union’s National Prison Project. “Every civil rights attorney in the country heard his call. Certainly, Justice Kennedy has opened the door and we’re all preparing to walk through it.”

The unusual opinion from the justice who wrote the court’s landmark gay marriage ruling was a boost to opponents who say solitary confinement violates the Constitution’s ban on cruel and unusual punishment. Some legal challenges are already being heard in lower courts, including a Virginia case that could make its way to the Supreme Court as early as the new term beginning in October.

Fettig says the words of Kennedy, often a swing vote in cases that divide the court’s liberal and conservative justices, send a strong signal to lower court judges “that this is a broad human rights issue.”

Kennedy’s clarion call is already gaining steam. Justices Stephen Breyer and Ruth Bader Ginsburg cited it favorably less than two weeks later in a dissent that questioned whether the death penalty was constitutional. The liberal justices condemned “the dehumanizing effect of solitary confinement” for death row inmates.

And President Barack Obama announced last month that he asked Attorney General Loretta Lynch to begin a review of the “overuse” of solitary confinement in federal prisons.

“The social science shows that an environment like that is often more likely to make inmates more alienated, more hostile, potentially more violent,” Obama told the annual conference of the NAACP in Philadelphia.

More than 80,000 inmates were held in some form of isolation in federal, state and local prisons in 2005, according to a report from the Bureau of Justice Statistics. The number has risen sharply since the 1990s with the rise of so-called “Supermax” prisons intended to segregate the most violent prisoners.

But some states have begun to re-examine the effectiveness of solitary confinement as studies have shown that it can lead to mental illness, hallucinations, self-mutilation and even suicide. Kennedy said the research confirms that “years on end of near-total isolation exacts a terrible price.”

Kennedy in recent years has expressed growing concerns over prison conditions and the rights of criminal defendants. He authored the court’s 5-4 ruling in 2011 that found overcrowding in California prisons led to inadequate inmate health care that was “cruel and unusual” under the Eighth Amendment. And in 2012, he sided with the court’s liberals in a 5-4 decision that threw out mandatory life in prison without parole for juveniles.

Last year, Colorado passed a law that bans prison officials from placing mentally ill inmates in long-term solitary confinement, unless there are special circumstances. Nevada and Texas have passed bills to study the issue and Maine and New Mexico have been working to reduce their use of solitary confinement.

“There’s a growing consensus that we’ve over-criminalized, over-punished and over-locked up an entire generation,” said Andrea Lyon, a criminal law professor and dean of Valparaiso University Law School in Indiana.

Lyon co-authored a 2005 report on Missouri’s policy of “mainstreaming” death row inmates into the general prison population. She said the data showed that death row inmates and others serving life sentences were five times less likely to commit violent offenses in prison than other inmates.

One case that could soon come before the court involves a challenge to Virginia’s practice of automatically holding death row inmates in solitary confinement. A federal judge ruled in 2013 that around-the-clock isolation of condemned prisoners is so severe that prison officials should make the decision on a case-by-case basis. But earlier this year, a divided federal appeals court in Richmond reversed.

Judge Diana Gribbon Motz, writing for the 2-1 majority, said the isolation that characterizes Virginia’s death row is “undeniably severe.” But she said the U.S. Supreme Court has long held that state correctional officials “have broad latitude to set prison conditions as they see fit.”

Attorneys for the inmate, Alfredo Prieto, have already appealed the case to the Supreme Court, and the justices have asked the state for a response.

There are other cases in the pipeline that more directly attack solitary confinement in general as being cruel and unusual punishment banned by the constitution. One is a California class action filed in 2012 on behalf of a group of prisoners in solitary confinement in Pelican Bay State Prison. That case is set for trial later this year.