Canada's highest court has thrown out the country's anti-prostitution laws in a victory for sex workers who said a ban on brothels and other measures made their profession more dangerous.
But the supreme court ruling, in a case brought by three women in the sex trade, drew criticism from the conservative government and religious leaders.
All three of Canada's prostitution-related laws - bans on keeping a brothel, making a living from prostitution and street soliciting - were struck down by the court. But the court gave parliament a year to respond with new legislation and said the existing laws would remain in place until then.
The decision threw the door open for a wide and complex debate on how Canada should regulate prostitution, which is not in itself illegal in the country.
Robert Leckey, a law professor at McGill University, said the court found that the law did nothing to increase safety, but suggested in its ruling that more finely-tailored rules might pass constitutional scrutiny in the future.
"Some of the (current) provisions actually limit sex workers' ability to protect themselves," he said.
The court found that Canada's prostitution laws violated the guarantee to life, liberty and security of the person, saying for instance, that the law forbidding people from making a living from prostitution was too broad.
It was intended "to target pimps and the parasitic, exploitative conduct in which they engage", the ruling said.
"The law, however, punishes everyone who lives on the avails of prostitution without distinguishing between those who exploit prostitutes and those who could increase the safety and security of prostitutes, for example, legitimate drivers, managers, or bodyguards."
Other countries, particularly in Europe, are having similar debates. Earlier this month, France's lower house of parliament passed a bill that would decriminalise prostitutes and fine their customers.
Some argue such laws empower prostitutes against their potential exploiters but others - including some prostitutes - say it only drives their practice further underground and makes it more dangerous.
Sex-trade workers in Canada stepped up their fight for safer working conditions following the serial killings of prostitutes by Robert Pickton in British Columbia. Pickton was convicted in 2007 of killing six women whose remains were found on his farm outside Vancouver.
Years earlier, authorities had closed down a Vancouver house for sex workers that many had considered a safe haven just as the disappearance of several prostitutes began raising fears that a serial killer was prowling the streets.
The supreme court ruling upheld an Ontario Court of Appeal ruling last year that, among other findings, struck down the ban on brothels on the grounds that it endangered sex workers by forcing them on to the streets.
"I am shocked and amazed that sex work and the sex work laws that affect our lives on a daily basis will within a year not cause us harm any more," said Amy Lebovitch, who brought the case along with Terri-Jean Bedford and Valerie Scott.
But justice minister Peter MacKay said the government was "concerned" by the decision and was "exploring all possible options to ensure the criminal law continues to address the significant harms that flow from prostitution to communities, those engaged in prostitution, and vulnerable persons".
Chief Justice Beverley McLachlin, writing on behalf of the court, said Canada's social landscape had changed since 1990, when the supreme court upheld a ban on street solicitation.
"These appeals and the cross-appeal are not about whether prostitution should be legal or not," she wrote. "They are about whether the laws parliament has enacted on how prostitution may be carried out pass constitutional muster. I conclude that they do not."
She added: "The harms identified by the courts below are grossly disproportionate to the deterrence of community disruption that is the object of the law. Parliament has the power to regulate against nuisances, but not at the cost of the health, safety and lives of prostitutes."
Don Hutchinson, vice president of the Evangelical Fellowship of Canada, a religious group that opposes the decriminalisation of prostitution, warned that the ruling could lead to increased human trafficking and victimisation of people.
"I think we're going to see an increase in cross-border traffic for those hoping to access our brothels," he said.