PORTLAND, Maine — A judge ruled Wednesday against OccupyMaine protesters’ continued encampment in Portland, the state’s last active around-the-clock presence inspired by the Occupy Wall Street movement. The city planned to issue an order to vacate, giving demonstrators at least 48 hours to decamp.

Superior Court Justice Thomas Warren ruled that the protesters, about 20 of whom sleep in the park, failed to meet city requirements for health and safety. He said that giving them the right to occupy the park for an extended period would conflict with others’ right to use it.

The city ordered protesters to leave the park on Dec. 15, but that was put on hold because of the lawsuit.

With the judge’s order, the city intended to give demonstrators at the encampment at least 48 hours to remove their belongings.

OccupyMaine attorney John Branson argued that the group’s continued encampment was protected by the First Amendment to the Constitution. He said the group hadn’t decided as of Wednesday afternoon whether to appeal.

Despite losing the motion, Branson was pleased the judge ruled that Occupy members were engaged in “expressive conduct” while camping in Lincoln Park. The justice rejected the city’s argument that the members were merely sleeping and eating in the park, not engaged in a protest that the public could understand, he said.

“We won a crucial victory on that, which is very important to OccupyMaine and its members,” he said.

Mayor Michael Brennan said demonstrators succeeded in making their voices heard on issues such as economic equality.

“Conversations concerning income disparity will continue here in Portland and throughout the nation,” he said. “Now that these issues have been brought to the forefront, it’s time for the discussion to move indoors.”

Other Occupy-related groups already have dissolved. A group camped out at Augusta’s Capitol Park lost a fight in federal court and a group at Bangor Public Library voluntarily left the grounds. The campers have been in Lincoln Park since October to protest what they describe as growing economic disparity and corporate greed.