PORTLAND, Ore. — Portland Mayor Charlie Hales on Tuesday announced the end of a pilot program that allowed homeless people to sleep on the streets undisturbed by law enforcement, saying it created confusion because some believed it legalized public camping.

The so-called “Safe Sleeping Guidelines” policy will end immediately, but several other pilot programs that were also rolled out in February in the famously liberal City of Roses will continue or even expand, his office said in an emailed statement.

“People believed that camping was made legal, and outreach workers and law enforcement struggled to educate people about the difference between a safe night’s sleep and unsanctioned camping,” the statement read, adding that police and residents felt the policy was “not practicable.”

Hales has walked a fine line in trying to address a growing problem with homelessness in the Pacific Northwest city while appeasing homeowners and businesses. His struggles mirror those in other West Coast cities, such as Seattle and San Francisco.

When Hales announced the safe sleeping pilot program in February, it was immediately controversial.

Neighborhood and business groups, including the Portland Business Alliance, sued. The Willamette Week, the city’s alternative weekly, sent a team of reporters to test the policy by pitching tents on the sidewalk in front of Hales’ home and the homes of other city elected officials.

The policy was supposed to be a temporary measure while the city found ways to get people into housing. Proposals included sanctioned encampments, RV parks and allowing people to pitch tents at night in a city parking lot.

But those solutions never materialized and Portland has not been able to erase a serious shortage of shelter beds.

While the safe sleep policy is ending, the statement said, the city still hopes to create planned outdoor shelters.

The city would provide basic services such as water and trash, as well as social services. A coalition of city and county government, nonprofits and business leaders would establish and manage the shelters.