The dispute has been a flashpoint in one of New York City’s most liberal neighborhoods.
About 200 homeless men will have to vacate a hotel on Manhattan’s Upper West Side that has been used as an emergency shelter during the pandemic, a judge ruled on Wednesday — the latest twist in a contentious case that has been a flashpoint in one of New York City’s most liberal enclaves.
The judge in Manhattan said that she would dismiss the proceedings and said that the court lacked jurisdiction over the dispute.
A spokesman for the city’s law department, Nicholas Paolucci, said that officials planned to begin moving the men after Thanksgiving.
“We’re pleased with the court’s decision which will allow the city to continue providing critical services to those who need it most,” Mr. Paolucci said in an email.
A lawyer for a downtown group that filed the lawsuit seeking to stop the relocation said that it planned to appeal.
The Upper West Side hotel, the Lucerne, which used to offer valet parking and spa services to tourists during pre-pandemic times, is one of 63 hotels the city has temporarily used as shelters to help prevent the spread of coronavirus at dormitory-style shelters.
The city’s strategy has sparked legal threats, protests, news conferences and the formation of several neighborhood groups — some opposed to these shelters and others in favor. But caught in the middle of the political push-and-pull are the displaced men whose lives have often been upended by evictions, unemployment and other traumatic events.
Michael Hiller, the lawyer who represented several of the men at the Lucerne, wrote in a text message: “Words cannot express how I feel about this decision greenlighting the city’s forcible relocation of the homeless residents of the Lucerne on the day before Thanksgiving.”
The decision is a blow to many of the men, who had said that they had found a sense of belonging and a measure of stability on the Upper West Side.
One of the men, who goes by the name Shams DaBaron and has become a spokesman for some of the men at the hotel, said in a statement, “We are hurt.”
“We have proven that the city does not care about our well-being, because if they did, we would be able to stay at a place where we are thriving,” Mr. DaBaron said.
Mr. Hiller said his clients were considering their legal options.
Mayor Bill de Blasio decided to move the men from the Lucerne Hotel in September after visiting the neighborhood and after a group formed by area residents hired Randy Mastro, a well-connected lawyer who has represented Mr. de Blasio in the past, to threaten a lawsuit against the city.
“The court recognized what we have been saying all along — that the city made the right decision here,” Mr. Mastro said in a statement.
The city first tried to move the men to a shelter for homeless families near the Empire State Building, but blowback from residents there led to the decision to send them to the Lower Manhattan hotel. The neighborhood group in the Financial District promptly sued the city to stop the move.
Mr. Mastro and lawyers for the city argued that the Radisson was a better option because it had more indoor space and more single rooms.
Mr. Hiller said that moving them would deprive them of services and jobs that they were able to get by being at the Lucerne.
Debra A. James, the Supreme Court justice who presided over the case, last week questioned the city’s rationale for moving the men.
“Because there were particularly powerful people, there was a decision made that the men have to go?” Judge James asked during the hearing, which lasted more than five hours spread over two days. “That’s a concern of mine.”
Soon after the men moved into the Lucerne, residents of the Upper West Side formed a private Facebook group that featured frequent posts blaming the men for public drug use, urinating in the street and harassment and at times described them using racist, dehumanizing language.
Other residents reached out to the men and formed a neighborhood group that worked with them to develop innovative services. Another organization arranged for a program that gave jobs to 50 men. Their lawyer said it would no longer be available if they had to leave the hotel.
According to the city’s Department of Homeless Services, moving about 9,500 people from shelters to hotels had saved many lives. The outlook for the residents in the main shelter system, which houses about 54,000 homeless people, was far more perilous earlier in the spring, when they were still living in dormitory-style shelters.
The mayor has defended his decision to relocate the men as part of an effort to return homeless people back to conventional shelters, but a more widespread effort to do so does not yet appear to be underway.
The men who had wanted to stay at the Lucerne may have, for the moment, lost in court, but Mr. DaBaron said, “By fighting and speaking out against this inhumanity, we have already won.”
He added: “Because we fought, we have maintained our dignity, to tell the city that while they may be able to move our bodies on a whim, they cannot silence our voices.”