WASHINGTON — The Supreme Court cleared the way Friday for cities to enforce bans on homeless people sleeping outside in public places, overturning a ruling from a California-based appeals court that found such laws amount to cruel and unusual punishment when shelter space is lacking.

The case is the high court’s most significant ruling on the issue in decades and comes as a rising number of people in the U.S. are without a permanent place to live.

In a 6-3 decision along ideological lines, the high court found that outdoor sleeping bans don’t violate the Eighth Amendment.

Western cities had argued that the ruling made it harder to manage outdoor encampments in public spaces, but homeless advocates said punishing people who need a place to sleep would criminalize homelessness.

In California, which contains one-third of the country’s homeless population, Democratic Gov. Gavin Newsom said the decision gives state and local officials the authority to clear “unsafe encampments” from the streets while acting with compassion. “This decision removes the legal ambiguities that have tied the hands of local officials for years,” he said.

Justice Neil Gorsuch acknowledged those concerns in the opinion he wrote for the majority.

“Homelessness is complex. Its causes are many. So may be the public policy responses required to address it,” he wrote.

He suggested that people who have no choice but to sleep outdoors could raise that as a “necessity defense” if they are ticketed or otherwise punished for violating a camping ban.

Homeless advocates, on the other hand, have said that allowing cities to punish people who have no other place to sleep would ultimately make the crisis worse. Cities had been allowed to regulate encampments under a U.S. 9th Circuit Court of Appeals ruling but couldn’t completely bar people from sleeping outdoors.

“Sleep is a biological necessity, not a crime,” said Justice Sonia Sotomayor, reading from the bench a dissent joined by her liberal colleagues. “Homelessness is a reality for so many Americans.”

Punishing people for something they can’t control, like homelessness, is cruel and unusual, she said. She warned that striking down Eighth Amendment arguments against camping bans likely won’t end the fights over the ordinances in court.

The case came from the rural Oregon town of Grants Pass, which appealed a ruling striking down local ordinances that fined people $295 for sleeping outside after tents began crowding public parks. The 9th Circuit Court of Appeals, which has jurisdiction over the nine Western states, has held since 2018 that such bans violate the Eighth Amendment in areas where there aren’t enough shelter beds.

Grants Pass Mayor Sara Bristol told The Associated Press that the city will not immediately start enforcing those local ordinances fining people for sleeping outside and that the City Council will need to review the decision and determine the next steps.

“This lawsuit was about whether cities have a right to enforce camping restrictions in public spaces, and I’m relieved that Grants Pass will be able to reclaim our city parks for recreation,” said Bristol, who serves in a nonpartisan position.

Attorney Theane Evangelis, who represented Grants Pass before the high court, applauded the ruling, saying the 9th Circuit decision had “tied the hands of local governments.”

“Years from now, I hope that we will look back on today’s watershed ruling as the turning point in America’s homelessness crisis,” she said.

In Portland, meanwhile, a spokesperson for the mayor’s office said the effect of the ruling would likely be muted since the state has separate legal limits on how cities can manage encampments. Seattle officials also expected a limited impact.

An attorney for homeless people who live in Grants Pass bemoaned the decision.

“We are disappointed that a majority of the court has decided that our Constitution allows a city to punish its homeless residents simply for sleeping outside with a blanket to survive the cold when there is nowhere else for them to go,” said Ed Johnson, director of litigation at the Oregon Law Center.

Friday’s ruling comes after homelessness in the United States grew a dramatic 12% last year to its highest reported level, as soaring rents and a decline in coronavirus pandemic assistance combined to put housing out of reach for more people.

More than 650,000 people are estimated to be homeless, the most since the country began using a yearly point-in-time survey in 2007.