(CNN) -- Key provisions of Canada's prostitution law were struck down Tuesday by an Ontario judge who said they endangered the people they were meant to protect.

Ontario Superior Court Justice Susan Himel sided with three sex workers who argued that restrictions on prostitution in Canada's Criminal Code forced them onto the streets to conduct business under threats of arrest and violence.

The Canadian government will appeal the decision and seek a stay of its enforcement, a spokeswoman for Justice Minister Rob Nicholson said Wednesday.

If the judge's ruling stands, sex workers will be able to legally conduct business from their homes and brothels, communicate freely with customers in public places and hire employees, such as drivers, receptionists and accountants, to help run prostitution businesses.

As of Tuesday, the ruling was set to take effect in 30 days so the government can figure out how to address its potential consequences.

If it does take effect, it will only apply to Ontario until the Canada Supreme Court weighs in on the matter. The provincial government also plans to join the federal government's appeal and prevent it from being immediately enforced, a spokesman for Ontario's Ministry of the Attorney General said.

"Ontario's position at the Superior Court was that these provisions of the Criminal Code are designed to prevent individuals, particularly young people, from being drawn into prostitution, to protect our communities from the negative impacts of street prostitution and to ensure that those who control, coerce or abuse prostitutes are held accountable for their actions. Thus, in our view, they are consistent with the core Charter values of human dignity and equality," spokesman Brendan Crawley said in an e-mail.

For Valerie Scott, one of the sex workers named in the lawsuit, the case was about the "blatant hypocrisy" of Canadian law.

"In theory, I can't be arrested simply for being a known prostitute, but practicing the profession is illegal," said Scott, 52. "I file income tax as a sex worker... I have that responsibility, but I don't have the rights that come with the responsibility."

Scott has worked on the streets, in massage parlors and as an exotic dancer since her teens. She said she and the other women named in the suit -- Terri-Jean Bedford and Amy Lebovitch -- raised the challenge on behalf of sex workers who want to operate legitimate businesses, complete with zoning permits, reimbursable expenses and workers' compensation.

"When I began all this I just wanted to be a sex worker, but I recognized pretty clearly and quickly that in order to be so, I have to change the laws of the country, and it's a big job," Scott said. "I never thought I'd spend my afternoons studying company law and income tax, municipal zoning regulations."

The constitutional challenge dealt with three provisions that prohibit keeping a common bawdy house, or brothel, communicating for the purposes of prostitution and living on the avails of the trade.

In the ruling, Himel noted that even though the act of prostitution is not illegal in Canada, "Parliament has seen fit to criminalize most aspects of prostitution," violating the sex workers' constitutional rights.

"These laws, individually and together, force prostitutes to choose between their liberty interest and their right to security of person as protected under the Canadian Charter of Rights and Freedoms," Himel wrote in a 132-page decision. "I find that the danger faced by prostitutes greatly outweighs any harm which may be faced by other members of the public."

The lawsuit was launched in an effort to bring Canada's policies in line with countries like New Zealand and Australia, where prostitution has been decriminalized, said Alan Young, a lawyer for the sex workers.

"Our position was if you remove certain legal provisions, you can conduct sex work in a safer way," the York University law school professor said.

Even so, Scott said the ruling was completely unexpected.

"We're not used to good news. We had several different press releases prepared but we didn't even bother to write one where we won everything," said Scott, the executive director of Sex Professionals of Canada, which advocates for the decriminalization of prostitution.

"We didn't think it would be possible."

Witnesses for both sides agreed that all prostitution carries a risk of violence and significant social stigma, Himel wrote in her decision, summing up more than two years' worth of evidence, discovery and testimony in the case.

Key matters in dispute were whether indoor prostitution is safer than street prostitution and whether current laws did sex workers more harm than good, Himel wrote.

Lawyers for the applicants submitted affidavits from current and former sex workers who shared the view that prostitution conducted in indoor venues was generally safer than street prostitution. They described strategies for ensuring safety, from working in a familiar environment to verifying services, prices and contact information with clients before an encounter, according to the judge's decision.

The clandestine nature of prostitution forces sex workers to establish client contacts hastily and without opportunity to assess the situation, experts on behalf of the sex workers testified. Provisions in the law limited the places and ways in which prostitution could be practiced safely and led to reluctance to report robberies or attacks, witnesses for the applicants said.

Former and current sex workers speaking for the government told stories of violence and drug abuse perpetrated by pimps and johns, the judge wrote. Crown experts said that no form of prostitution is safe because it is an inherently harmful form of violence against women.

The judge also heard from police officers from across Canada with experience in enforcing prostitution-related provisions. They generally characterized sex workers as victims, commonly poverty-stricken and drug-addicted. Prostitution, the judge wrote, was generally described as a harmful activity with links to drugs, violence, organized crime and child exploitation.

Under cross-examination, the officers conceded that the level of violence on the street is worse than it is indoors, and that safety precautions can be taken in indoor locations to reduce violence, the judge noted.

Scott said she applied to the University of Toronto's business school with a business plan for running a brothel and was accepted. She plans to attend in April.

"I like the work, I like the people, I like the clients, I set my own hours, I set my own price structure, I call the shots with what I will and will not do," she said. "Personally, I took to sex work like a duck to water. If it's for you, if the person likes the job, it can be a very good job. And that's what it is -- a job. It's not a lifestyle."