SAN SALVADOR (Reuters) - El Salvador lawmakers on Thursday unanimously voted to abolish a controversial, 23-year-old law that allowed men to marry underage girls they had impregnated, a practice that critics charged protected sexual assailants from criminal prosecution.

It is illegal for people under the age of 18 in El Salvador to marry, but an exception was made in 1994, allowing underage girls who are pregnant to wed with parental approval.

Activists and even the government argue that the rule is often abused, particularly in poor, rural areas, where shamed families marry off their daughters to their alleged rapists so they will not be forced to bring up the child alone.

Congress removed this part of its family code, although the legal age for marriage remains unchanged.

“This reform is an important element to begin to generate a change of conduct,” said UNICEF’s Maria de Mejia. “This is a cultural question that has roots in the discriminatory, patrimonial practices facing girls in ... El Salvador.”

The country is home to more than 22,000 minors who are married or co-habiting, according to El Salvador government data.

UNICEF estimates there were more than 25,000 births by underage mothers in 2015.