PORTLAND, Ore. — When Occupy Wall Street protesters took over two parks in Portland’s soggy downtown, they pitched 300 tents and offered free food, medical care and shelter to anyone. They weren’t just building, like so many of their brethren across the nation, a community to protest what they see as corporate greed.

They also created an ideal place for the homeless. Some were already living in the parks, while others were drawn from elsewhere to the encampment’s open doors.

Now, protesters from Portland to Los Angeles to Atlanta are trying to distinguish between homeless people who are joining their movement and those who are there for the amenities. When night falls in Portland, for instance, protesters have been dealing with fights, drunken arguments and the display of the occasional knife.

However, many homeless people say the protests have helped them speak out against the economic troubles that sent them to the streets in the first place.

“The city wasn’t giving us what we needed,” said Joseph Gordon, 31, who trekked his way from Cincinnati two months ago and said there is nearly always enough food but never enough shelter. “You can’t feed your problem away. It took this camp to show people how it really is.”

As protesters across the country try to coalesce around an agenda in the coming weeks and months, they are trying to make life work in camps that have become small-scale replicas of the cities where they were erected.

And just like those cities, they are dealing with many of the same problems that local governments have struggled for decades to solve.

Some organizers view the protest and the inclusion of the homeless as a chance to demonstrate their political ideals. They see the possibility to show that the homeless are not hopeless and that they, too, can become a functional part of society.

In Portland, the protest has swallowed up two square blocks. There are shaggy-haired college kids, do-gooder hippies and couples with their young children.  Rain falls daily, and dry socks are at a premium.

At the center of the camp are the medical, information, library and wellness tents. Along one side are families, who established a children’s play area. On the opposite side, the city’s anarchist faction and long-term homeless sleep.

“It’s a big, messy, beautiful thing,” said Kat Enyeart, 25, a medic who says she spends half her time tending to the homeless, some of whom are physically and mentally ill.

As the occupation enters its fourth week, divisions have begun to emerge. Without the ability to enforce laws and with little capacity to deal with disruptive or even violent people, the camp is holding together as it struggles to maintain a sense of order and purpose.

One man recently created a stir when he registered with police as a sex offender living in the park. A man with mental health problems threatened to spread AIDS via a syringe.  

Last week, a homeless man menaced a crowd of spectators with a pair of scissors. Micaiah Dutt, a four-tour veteran of the Iraq war, and two other former soldiers had no problem tackling and subduing the man. Other members of the protest’s volunteer security detail have been hit and threatened with knives.

Dutt said he felt helpless at times and noted that the man he helped subdue could, in theory, press assault charges .

“I served four tours in Iraq, and I felt more safe there at times than here,” he told a gathering of protest organizers. “There, I had a weapon and knew the people around me were with me. Here, I don’t know.”

Dutt said the protests are not just about the radicals and the politicians. “It’s about our community taking care of itself because the city, county and federal governments have neglected this population,” he said.

In Los Angeles, protesters face similar issues: Homeless transplants from the city’s Skid Row have set up their tents within the larger tent city. No violence has been reported, but protest organizers are trying to discourage people who are at the encampment only for the amenities.

Some, like Steven Pierieto, said they’ve fallen on difficult times but are at the protest because they support the movement. They scorn those who come for the sandwiches but never lift a protest sign.

Life in camp, Pierieto said, is far better than life on Skid Row.

“I don’t have to smell urine. I don’t have to see people smoking crack. I have Porta-Potties right here. It’s peaceful,” he said.

In Oakland, Calif., where the camp on the City Hall lawn has become a tourist attraction, organizer Susanne Sarley said getting along for a common cause will be an ongoing challenge.

“This is the homeless people’s turf,” Sarley said. “This area we’re occupying is their home. We can’t move them. We have to cooperate and respect the community that we’re in.”

The friction between the homeless and the protesters has not been the case in other cities. In Atlanta, for instance, it has been a benefit. The homeless have helped novice protesters learn how to put up tents that can withstand wind gusts, maintain peace in close quarters and survive the outdoors.

Billy Jones, 28, provides security at the protests. Jones said he’s not just looking for free food.

“Don’t have the misconception that most homeless people are always out for a meal,” Jones said. “I’m here because there are things I can lend that are helpful to the movement. I can get food anywhere.”