VANCOUVER - The homeless community in British Columbia's Fraser Valley has won the right to camp outside after a judge struck down a controversial municipal bylaw that banned tents in local parks.

Chief Justice Christopher Hinkson ruled on Wednesday that homeless people in Abbotsford, B.C., have the right to erect temporary shelters in parks between 7 p.m. and 9 a.m. because of a lack of accessible shelter space in the city.

The legal action by Abbotsford was the latest attempt to evict the homeless campers that began with issuing bylaw notices, but escalated to spreading pepper spray and chicken manure on the camps and finally destroying or disposing of tents and other personal property.

The 81-page ruling found that a prohibition on camping violated their charter rights to life, liberty and the security of person.

"Allowing the city's homeless to set up shelters overnight while taking them down during the day would reasonably balance the needs of the homeless and the rights of other residents of the city," Hinkson wrote.

His ruling referenced a 2008 decision, also from B.C. Supreme Court, that upheld the right of homeless people in Victoria to erect temporary shelters in city parks.

Hinkson stressed that the temporary, overnight nature of the camping permission would help address poor living conditions that he believed arose out of more permanent makeshift settlements, including the proliferation of drug paraphernalia, garbage, human waste and criminal elements.

The judge rejected the city's claim that homeless people prefer to live outside.

"To assert that homelessness is a choice ignores realities such as poverty, low income, lack of work opportunities, the decline in public assistance, the structure and administration of government support, the lack of affordable housing, addiction disorders and mental illness," wrote Hinkson in his ruling.

The ruling included a harsh rebuke of the city's tactics used to displace the campers, including municipal workers using shovels to dump the chicken manure from city trucks onto an encampment.

He called the actions "disgraceful and worthy of the court's disapproval."

While Hinkson recognized that forcing the continual displacement of the city's homeless causes them "impaired sleep and serious psychological pain and stress," he fell short of ordering Abbotsford to pay damages.

In the same ruling, Hinkson dismissed Abbotsford's request for a permanent injunction against homeless encampments on city property. Abbotsford has more than a thousand hectares of parkland.

City officials have not said whether they would appeal the decision. They said city lawyers were reviewing the decision and a statement would be issued.

Rich Coleman, B.C.'s minister in charge of housing, said the current Abbotsford council is compassionate, unlike like previous council that "didn't treat the homeless situation particularly well."

He said council is now working with the province on construction and planning of a number of buildings for those who need shelter and the city is developing a cold weather strategy.

"But, certainly, Abbotsford is a better place than (it) was a few years ago when this particular instance led to this court case," he said in an interview in Victoria.

OPINION The global food system is amazing. We have created a process that can put enormous diversity of food onto any plate in our province, assuming the plate will be sliding in front of someone who can afford to pay