Occupy Wall Street protesters are back inside the lower Manhattan park that has been their home for almost two months, despite losing a tense legal battle with New York mayor Michael Bloomberg and the site's owners.

Almost 16 hours after police moved in and cleared Zuccotti Park of the protesters and their tents, a New York supreme court judge ruled that the city had not breached their first amendment rights.

Earlier, the mayor had defended the decision to clear the site on the basis that "health and safety conditions became intolerable".

After a tense day of stand-offs between police and protesters, and mounting criticism of Bloomberg's tactics, judge Michael Stallman ruled that demonstrators did not have the right to erect tents or other structures in the park.

Scores of reporters had gathered outside room 315 at the supreme court to await the ruling, which had been promised for 3.15pm but finally came 90 minutes after that. The news was relayed by a WNYC radio reporter who had managed to read over the shoulder of a lawyer.

The decision will make it increasingly difficult for demonstrators to continue their occupation as winter approaches.

Judge Stallman denied an attempt by the protesters' lawyers to extend a temporary restraining order which had been issued early on Tuesday morning by a different judge, but which had been ignored throughout the day by city authorities and the New York police department, who refused to reopen the park.

Occupy Wall Street "have not demonstrated a first amendment right to remain in Zuccotti Park, along with their tents, structures, generators and other installations." Judge Stallman said in his ruling. "Neither have the applicants shown a right to a temporary restraining order that would restrict the city's enforcement of law so as to promote public health and safety."

But the ruling did not prevent the protesters from returning to the park, and within an hour the police opened the gates and allowed them back in, subject to bag searches to ensure they were not carrying tents, sleeping bags or other camping equipment.

Lawyers who support the Occupy movement were dismayed, however. Michael Ratner, president of Centre for Constitutional Rights , said: "This is an incredible denial of our constitutional rights. We have very clear precedents that say people can sleep in the streets of New York as an act of protest."

Ratner said that massive marches were planned for Thursday 17 November. "This movement is ultimately not about what happens in the courts, it's about what happens in the streets."

On the steps of the court, lawyers from the National Lawyers Guild, who represented Occupy protesters, told a waiting crowd of reporters that they would consider an appeal.

Yetta Kurland said: "We're obviously disappointed with the decision by judge Stallman" and equally disappointed that he went the other way from an earlier judge who had granted an emergency order allowing protesters the right to stay in the park with their belongings.

"This has not stopped the movement," she added. "The 99% will continue to show up, continue to express themselves."

Asked if there was anything in the judge's decision that would prevent protesters bringing sleeping bags, Alan Levine, another of the five lawyers representing the protesters said: "There's nothing to prevent them sleeping there tonight. If there's going to be a right to a 24-hour occupation we believe that's protected by the first amendment. That right has along with it the attendant right to be protected from the elements. The judge didn't disagree."

New York police department spokesman Lieutenant John Grimpel said: "It might take a while, but the park is in the process of being re-opened." He said that people would not be allowed back in the park if they were carrying sleeping bags or tents.

Bloomberg's decision to clear the camp came in response to a letter from the owners Brookfield Properties. He said the city had planned to reopen the park on Tuesday morning after the protesters' tents and tarps had been removed and the stone steps had been cleaned.

"This morning we planned to re-open Zuccotti Park to the public, including any protestors, at approximately 8:00am when the cleaning was completed,'' he said in a statement. "The opening of the park was delayed due to legal action taken against the City, but Zuccotti Park is now open to the public.

"The court's ruling vindicates our position that First Amendment rights do not include the right to endanger the public or infringe on the rights of others by taking over a public space with tents and tarps. The City has the ultimate responsibility to protect public health and safety and we will continue to ensure that everyone can express themselves in New York City."

Hi decision was attacked by other New York officials. City comptroller John Liu said: "Going in and forcibly removing the protesters in the dead of night sends the wrong message. City hall should have continued to talk with the protesters in the light of day if it wanted them removed, instead of evicting them in the middle of the night. There seems to be no compelling reason for this action at this time. The protesters have a right to be heard."

New York City councilman Ydanis Rodríguez was one of the nearly 200 people arrested – 142 in the park and 50 to 60 in the streets nearby, according to police. New York authorities attempted to impose a media blackout on the raid, banning helicopters from airspace above the park and cordoning off media. Several members of the press were arrested despite having official accreditation, while others had their accreditation confiscated.

By Tuesday evening, several hundred protesters were back in the park, minus sleeping bags or tents. Lee Debo, who lives in the Bronx, said he was happy to be back. "It is a compromise but I woke up this morning hearing bad news and took the day off to come down," he said. "I was expecting the worst but here we are. You take what you can get."

Megan Hanley, a student and actress, said the park was a symbol but the movement was bigger. "The movement has outgrown this space anyway," she said.