PHNOM PENH, Cambodia — Thirty-two Cambodian women who were charged with human trafficking for serving as surrogate mothers have been provisionally released from detention after agreeing to keep the babies rather than giving them up as originally planned, officials said Wednesday.

Bun Samkhan, a spokeswoman for the National Committee for Counter-Trafficking, said the women, who were charged in July with violating surrogacy and human trafficking laws, were released on bail in three groups, the last 17 on Wednesday.

A senior police officer who works at the same agency, speaking on condition of anonymity because he was not authorized to talk publicly, said the women were released on humanitarian grounds.

He said they had committed crimes but their babies are innocent, and for that reason the committee requested that the court free them. They had been held at a police hospital.

The identifies of the fathers have not been released.

Acting as an intermediary between an adoptive parent and a pregnant woman carries a penalty of one to six months in prison. The human trafficking offense is punishable by seven to 15 years' imprisonment.

A Chinese man and four Cambodian women accused of managing the business were charged with the same offenses.

Bun Samkhan said her committee requested the release of the surrogate mothers so they could take care of their babies, with the condition that they keep the children.

"We have told them clearly that these babies belong to you, so you have to take care of them until they grow up, and not sell them," Bun Samkhan said. "And they agreed."

Cambodian women who have served as surrogates have said they were offered as much as $10,000. The average annual household income in Cambodia is about $1,490, according to the International Monetary Fund. It was not known how much the women in this group were paid.

Cambodia passed a law specifically targeting surrogacy in 2016 as the country was becoming a popular destination for foreign would-be parents seeking women to give birth to their children.

Developing countries are popular for surrogacy because costs are much lower than in countries such as the United States and Australia, where surrogate services can cost around $150,000. The surrogacy business boomed in Cambodia after it was put under tight restrictions in neighboring Thailand. There also were crackdowns in India and Nepal. After Cambodia's crackdown, the trade shifted to neighboring Laos.

In July last year, a Cambodian court sentenced an Australian woman and two Cambodian associates to 1 1/2 years in prison for providing commercial surrogacy services. The Australian woman was quietly freed earlier this year.