However, the Ontario Court of Appeal upheld the ban on soliciting as a reasonable way to protect communities.
It also "read in" wording to the criminalization of living on the avails of prostitution to make it clear that exploitation of prostitutes should be illegal.
"Prostitution is a controversial topic, one that provokes heated and heartfelt debate about morality, equality, personal autonomy and safety," the court wrote in a split decision stretching to 132 pages.
"It is not the court's role to engage in that debate. Our role is to decide whether or not the challenged laws accord with the constitution."
The ruling came in an appeal by the government of a lower court ruling that found the three provisions unconstitutional in that they contributed to the dangers faced by prostitutes.
The five-panel judge only agreed fully with the lower court in finding that the law against brothels was too broad because "it captures conduct that is unlikely to lead to the problems Parliament seeks to curtail."
The court also found the impact is "grossly disproportionate" to the law's intent because "the safest way to sell sex is for a prostitute to work indoors in a location under her control."
At the same time, it suspended its declaration for 12 months to give Parliament an opportunity to draft a new law if it so chooses.
At the same time, the court said the effective ban on street prostitution makes sense because harm to the community is real.
"While street prostitution poses real and grave dangers to the prostitutes themselves, it also has a profound impact on the members of the surrounding community," the justices wrote.
As such, the court found, the ban on communicating publicly for the purposes of prostitution is reasonable.
In addition, by allowing prostitutes to move indoors given the decriminalization of brothels, any harm caused by the ban on solicitation would be mitigated, the court said.
In a dissenting opinion on that score, two justices said they agreed with the trial judge's finding that the danger posed to street prostitutes by the ban on communicating should override the goal of combating social nuisance.
"The world in which street prostitutes actually operate is a world of dark streets and barren, isolated, silent places," the dissenters wrote.
"It is a dangerous world, with always the risk of violence and even death."
When it comes to living on the avails of prostitution, the court said the law could be reworded to specifically exclude the exploitation of prostitutes.
"This offence aims to protect vulnerable persons from being coerced, pressured or emotionally manipulated into prostitution," the court said.
The objective is to prevent "pimps from exploiting prostitutes and from profiting from the prostitution of others" but it also captures others such as a prostitute's bodyguards, accountant or receptionist.
"It captures conduct that is no way exploitative," the justices wrote.
However, the justices "read" words of limitation into the law so that it bars living on the avails "in circumstances of exploitation."
"This aligns the language of the provision with the vital legislative goal that animates it and cures the constitutional defect," they said.
"It introduces the requirement that the accused has unfairly taken advantage of the prostitute in his dealings with her."
They stayed that part of the ruling for 30 days.