SUNTI ANI, an Indonesian sex worker, has been arrested more times than she can count. She lives in Malang, in the province of East Java, where her trade was criminalised in 2014 on the basis that prostitution is “prohibited by all religions”. Until then, she worked in a brothel. But after, she says, “we were forced to see our clients in cafés and on the streets.” She earns less money than before. And she is more wary of the police, who once used her possession of a condom as evidence against her.

Listen to this story

Enjoy more audio and podcasts on iOS or Android.

Indonesia has no national law that directly regulates prostitution. But some local governments have used an ambiguous “Crimes Against Morals” law to ban sex work in their districts. In 2014 Malang shut down brothels as a “birthday present” to the district, timing the closure to coincide with the 1,254th anniversary of its founding. An official told sex workers to “get a job that is more pleasing to God”.

Some prostitutes in Malang stayed at the brothels and worked clandestinely. Others took their work to the streets. Some gave up on sex work and returned to their villages. Where once such work was done during the day, it shifted to the night. A sign in a brothel that said “condoms must be used here” was changed to advertise karaoke, though opportunities for warbling to old chartbusters proved scarce. Ms Sunti Ani took up the God-pleasing vocation of waiting tables but quit when her co-workers found out about her former career.

Even as Malang embarked on its crackdown on prostitution, brothels in two nearby districts remained open. That presented researchers with a control group. Comparing indicators from Malang and its neighbours, Lisa Cameron of the University of Melbourne, Jennifer Seager of George Washington University and Manisha Shah of the University of California, Los Angeles found that within six months of criminalisation, sexually transmitted infections (STIs) among sex workers in Malang had risen by 58%, even as they remained stable in the control group. Nor was the policy effective at reducing prostitution: though the sex market initially shrank, it grew back to its original size after five years.

Public-health measures suffered as a result of the ban. Many prostitutes in Malang lost access to the STI checks and cheap condoms that non-profits and local health officials used to provide. Some organisations stopped administering services to sex workers because they were wary of aiding a criminalised trade. Those that continued have had a harder time locating sex workers because they are no longer centralised in brothels. Condom prices tripled as subsidised ones disappeared. As sex workers’ earnings fell, some compensated by offering clients unprotected sex, for which they can charge more.

The findings fit into an existing body of evidence that suggests criminalising sex work leads to bad outcomes. Negotiations may be rushed if sex workers must keep an eye out for the police, and this reduces their bargaining power. They become more vulnerable to assaults if they are reluctant to report them. Criminal records often prevent them from getting other kinds of jobs. One study suggests that decriminalising sex work may reduce rapes, even among the general population. These costs can be particularly high in poor countries, where relatively more women sell sex. For now, Ms Sunti Ani continues for the sake of her family. Her sex work pays for her daughter’s education.

This article appeared in the Asia section of the print edition under the headline “Perverse outcomes”