BERLIN — Germany's Cabinet on Wednesday approved a bill that would annul the convictions of thousands of gay men under a law criminalizing homosexuality that was applied zealously in post-World War II West Germany.

The decision also clears the way for compensation for those still alive who were convicted under the so-called Paragraph 175 outlawing sexual relations between men.

The legislation was introduced in the 19th century, toughened under Nazi rule and retained in that form by West Germany, which convicted some 50,000 men between 1949 and 1969.

Homosexuality was decriminalized in 1969 but the legislation wasn't taken off the books entirely until 1994.

The bill approved Wednesday by Chancellor Angela Merkel's Cabinet of conservatives and center-left Social Democrats still requires parliamentary approval. It foresees compensation of 3,000 euros ($3,230) for each conviction, plus 1,500 euros for every year of jail time that convicted men started.

German Justice Minister Heiko Maas addresses the press in Berlin, Germany, 22 March 2017. Clemens Bilan / EPA

"The rehabilitation of men who ended up in court purely because of their homosexuality is long overdue," Justice Minister Heiko Maas said. "They were persecuted, punished and ostracized by the German state just because of their love for men, because of their sexual identity."

The Morning Rundown Get a head start on the morning's top stories. This site is protected by recaptcha

"The strength of a state of law is reflected in having the strength to correct its own mistakes," he said. "We have not just the right but the obligation to act."

In 2000, Germany's parliament approved a resolution regretting the fact that Paragraph 175 was retained after the war. Two years later, it annulled the convictions of gay men under Nazi rule, but not post-war convictions.

The Lesbian and Gay Federation in Germany "welcomes the fact that, after long decades of ignorance, legal consequences are being drawn from the serious mass human rights violations that were committed against homosexual people by the democratic state," spokesman Helmut Metzner said.

The planned legal rehabilitation will be automatic and won't require applications, though people will have to apply to prosecutors if they want formal certification. It will exclude men who were convicted for homosexual activities with children or for acts that involved violence or threats.

It also will apply to men convicted in communist East Germany, which had a milder version of Paragraph 175 on the books and decriminalized homosexuality in 1968.

About 4,300 men are believed to have been convicted there. In all, some 68,300 people were convicted under various forms of Paragraph 175 in both German states before it was scrapped in 1994.

Related: UK to Pardon Thousands of Gay Men Under 'Turing's Law'

In addition to individual compensation, the government plans to give an annual 500,000 euros in funding to the Magnus Hirschfeld Foundation, named after a pioneering German sex researcher and gay-rights activist of the post-World War I period.

The foundation is working on documenting the stories of men convicted under Paragraph 175.

In October, the British government announced that thousands of men convicted under now-abolished laws outlawing homosexuality would receive posthumous pardons, while those still alive will be eligible to have their criminal records wiped clean.

A few other countries, including Canada and New Zealand, are considering pardons for people convicted under now-repealed laws against gay sex.

Follow NBC Out on Twitter, Facebook and Instagram