French lawmakers have passed a law that makes it illegal to pay for sex and imposes fines of up to €3,750 (£3,027, $4,274) for those buying sexual acts.

Those convicted would also have to attend classes to learn about the conditions faced by prostitutes. It has taken more than two years to pass the controversial legislation because of differences between the two houses of parliament over the issue.

BBC reported that some sex workers protested against the law during the final debate. The demonstrators outside parliament in Paris, numbering about 60, carried banners and placards one of which read: “Don’t liberate me, I’ll take care of myself”.

The law was passed in the final vote on the bill in the lower house of parliament by 64 to 12 with 11 abstentions. It supersedes legislation from 2003 that penalised sex workers for soliciting. Prostitution itself is not a crime in France, but pimping, human trafficking, brothels and and buying sex from a minor are all already against the law.

Members of the Strass sex workers’ union said the law will affect the livelihoods of France’s sex workers, estimated to number between 30,000 and 40,000. Sweden was the first country to criminalise those who pay for sex rather than the prostitutes, introducing the law in 1999. Other countries have since adopted the so-called “Nordic model”: Norway in 2008, Iceland in 2009, and Northern Ireland in 2014. Earlier this year, the European parliament approved a resolution calling for the law to be adopted throughout the continent.

But many advocacy groups warn the model makes sex work more dangerous. Catherine Stephens, an activist with the United Kingdom-based International Union of Sex Workers, and a sex worker herself, said criminalisation makes those in the industry “much more likely to have to accept clients who are obscuring their identity, which benefits people who want to perpetrate violence”.

Ms Stephens told the BBC that criminalising those who wish to purchase sex makes them less likely to report concerns about a sex worker’s wellbeing. “We have had cases where clients have helped people escape from situations of coercion … Criminalising the client actively works against that, discouraging them from coming forward. We need to create a situation in which it is easy to report harm, violence and coercion. Blanket criminalisation of premises, brothels, or clients absolutely works against that.”

Amnesty International said that laws against buying sex “mean that sex workers have to take more risks to protect buyers from detection by the police”. The charity said sex workers have reported being asked to visit customers’ homes to help them avoid police, instead of meeting them in safer environments.

Supporters of the law argue that it increases safety. Anne-Cecile Mailfert, the president of the Women’s Foundation in France, which provides support to women’s rights organisations, says sex workers are better able to seek police protection if they need it.

She told the BBC: “We are giving to the prostituted person a new tool to defend themselves and protect themselves. If they don’t want to do that then actually they just don’t have to call the police. But if anything happens, if the client is violent, if anything wrong happens, then now they have the law on their side.”

The legislation will also make it easier for foreign prostitutes to get a temporary residence permit in France if they agree to find jobs outside prostitution, says Socialist MP Maud Olivier, who sponsored the legislation.

He told the Associated Press: “The most important aspect of this law is to accompany prostitutes and give them identity papers, because we know that 85% of prostitutes here are victims of trafficking.”