TOKYO (Reuters) - Japan on Wednesday passed a law compensating tens of thousands of people who were sterilized, often without their consent, under a government program to prevent the birth of “inferior descendants” that remained in effect until 1996.

Many of the victims were physically or cognitively disabled, and others suffered from mental illness, leprosy - now a curable affliction known as Hansen’s disease - or simply had behavioral problems.

The law, which states that “we seriously reflect and deeply apologize”, promises to pay each victim, many of whom were in their teens or younger when operated upon, 3.2 million yen ($29,000) in compensation.

It was unanimously passed by the upper house of parliament, after previously passing the more powerful lower house.

Prime Minister Shinzo Abe issued a statement apologizing and saying every effort would be made to ensure that society did away with discrimination against the disabled.

“During the period the law was in effect, many people were subjected to operations that made them unable to have children based on their having a disability or another chronic illness, causing them great suffering,” he said.

“As the government that carried out this law, after deep reflection, I would like to apologize from the bottom of my heart.”

According to the new law, victims have five years to apply for compensation, subject to approval by a board of experts.

Japan’s “Eugenics Protection Law” came into effect in 1948 as it struggled with food shortages and rebuilding a war-ravaged nation, and was only revoked in 1996.

During that time, an estimated 25,000 people were sterilized, with at least 16,500 not giving consent, which the eugenics board could order if it signed off on the procedures after an often cursory review. Few records remain.

Sterilizations peaked in the 1960s and 1970s, with the last surgery under the law carried out in 1993.

About 20 victims around Japan are suing the government for compensation and an apology. The first judgment in one of these cases is expected in late May.

Though the most notorious eugenics laws were imposed by Nazi Germany, Japan is not the only nation with similar programs in peacetime. Most other countries revoked their laws in the 1970s.