Critics say the nearly three-decade-old system has little to do with education.

“Sex workers are subjected to police violence… forced labour, compulsory testing for sexually transmitted disease… humiliation and physical violence at these centres,” said Shen Tingting, director of advocacy and policy at Asia Catalyst, an NGO working with marginalised groups in the region.

Abolishing this system is a “significant positive step,” she said.

The arbitrary detention system will cease from December 29, and those held at “education centers” should be released immediately, state news agency Xinhua reported.

There has been a public push to close the centres ever since China’s top legislative committee abolished its system of “re-education through labour camps” in 2013.

Shutting the labour camps — introduced as a speedy way to handle petty offenders — ended a practice long criticised by human rights groups.

Yet authorities retained the right to detain sex workers and their clients, and in 2014 police announced that popular actor Huang Haibo would be held for six months for having solicited a prostitute.

That prompted a rare instance of dissent from state media, which questioned the system.

Although illegal, prostitution remains widespread in China, with an estimated several million sex workers.

Under current laws prostitutes and their clients can be fined up to 5,000 yuan ($714) and face up to 15 days of administrative detention.

“Sex workers’ issues seldom sits on the agenda of the government,” said Shen, adding that abolishing detention centers is only a small step towards safeguarding the rights of prostitutes.

“Chinese law and policies focus on prohibition and cracking down on sex work rather than providing a framework to ensure the health and safety of sex work as a profession.