The Supreme Court of Canada has unanimously struck down the nation's anti-prostitution laws.
The high court deemed laws prohibiting brothels, communicating in public with clients and living on the profits of prostitution to be too sweeping.
The ruling follows a court challenge filed by former and current sex workers.
The justices' decision gives the Canadian government one year to craft new legislation.
All nine of the court's judges ruled in favour of striking the laws down, finding they were "grossly disproportionate".
"It is not a crime in Canada to sell sex for money," Chief Justice Beverley McLachlin wrote in Friday's decision.
Canada's criminal code currently makes it illegal to keep a brothel, communicate in public about acts of prostitution or live off its proceeds.
But Justice McLachlin wrote: "Parliament has the power to regulate against nuisances, but not at the cost of the health, safety and lives of prostitutes.
"The prohibitions at issue do not merely impose conditions on how prostitutes operate.
"They go a critical step further, by imposing dangerous conditions on prostitution; they prevent people engaged in a risky - but legal - activity from taking steps to protect themselves from the risks."
Under the ruling, the Canadian parliament has 12 months to rewrite the legislation or it will be withdrawn.
Anti-prostitution laws will continue to be enforced in the meantime.
Canadian Justice Minister Peter MacKay said the government would reflect on "this very complex matter".
"We are reviewing the decision and are 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," his statement said.
A Canadian women's rights group condemned the court's decision, saying it was a "sad day".
"We've now had confirmed that it's OK to buy and sell women and girls in this country," Kim Pate, executive director of the Canadian Association of Elizabeth Fry Societies, told the Canadian Broadcasting Corporation.
"I think generations to come - our daughters, their granddaughters and on - will look back and say, 'What were they thinking?'"
'Compulsion from pimps'
A constitutional challenge by three women with experience in the sex trade, Terri-Jean Bedford, Amy Lebovitch and Valerie Scott, prompted the case.
In March, the Ontario Court of Appeal upheld a ban on communicating for the purpose of prostitution, a decision which Ms Bedford challenged.
The federal and Ontario governments appealed against two other parts of that decision: striking down the law against brothels; and limiting the ban on living off the avails of prostitution.
The Canadian authorities argued that they should be entitled to legislate against prostitution as they "see fit".
Lawyers for the Ottawa government reportedly claimed "if the conditions imposed by the law prejudice [sex workers'] security, it is their choice to engage in the activity, not the law, that is the cause".
But the Supreme Court ruled it was not a choice for many.
"Whether because of financial desperation, drug addictions, mental illness, or compulsion from pimps, they often have little choice but to sell their bodies for money," Justice McLachlin wrote.