SAN SALVADOR, El Salvador (AP) — El Salvador and Guatemala have joined a trend in clamping down on child marriage by passing legislation that would outlaw marriage with minors.

Legislation passed in both countries Thursday to ban such unions even in cases of parental consent or pregnancy.

An El Salvador government survey in 2015 found that there were 22,361 minors between the ages of 12 and 17 who had married or lived in a common-law relationship. Six out of 10 of the minors who were in a relationship with an adult lived in the country's rural areas.

Zaira Navas, director of El Salvador's National Council on Childhood and Adolescence, said the previous law had allowed adults to avoid legal charges for sexual assault through marriage.

The United Nations' children's advocate UNICEF and other supporters applauded the change.

"El Salvador's move to ban child marriage is great news, and an important step forward in the effort to end child marriage in Latin America and around the world," said Heather Barr, a senior researcher with Human Rights Watch. She said El Salvador was among the countries that committed under the 2016 Sustainable Development Goals to end child marriage by 2030.

"In many countries, there is a serious gap between laws on child marriage and enforcement — so it will be important to see what steps the El Salvador government will take to make sure that the new law translates into change on the ground and better protection for girls," Barr said in an email Friday.

The legislation in Guatemala, which will go into effect in a month, eliminates a provision that allowed judges to authorize marriages between adults and children 16 and older.

Leonel Dubon, director of the Childhood Refuge, which cares for abused children, predicted it would help change prevalent macho attitudes.

"A cultural pattern exists that permits giving girls to adults," Dubon said. "They continue seeing girls as objects of pleasure and not as having rights."

The new laws are part of a regional trend in Central America.

In July, Honduras' legislature also unanimously passed a bill prohibiting the marriage of anyone younger than 18 even with parental consent or in pregnancy cases. Barr said Costa Rica has also reformed its laws on the issue.

According to UNICEF, 11 percent of girls aged 15 to 19 in Latin America and the Caribbean are currently married or in a union.

___

Associated Press writers Christopher Sherman in Mexico City and Sonia Perez D. in Guatemala City contributed to this report.