Germany's president has asked gays for forgiveness for decades of suffering and injustice they endured as a result of repressive laws in Germany in the Nazi era and after World War II.

Frank-Walter Steinmeier spoke Sunday in a ceremony marking the persecution of gays by the Hitler regime.

The dpa news agency quoted Steinmeier as saying that the harsh treatment continued in the post-war era, in both parts of a then-divided Germany, where homosexuality for years remained a criminal offense.

The president says "this is why I'm asking for forgiveness today, for all the suffering and injustice, and the silence that followed."

Steinmeier says he wants to reassure "all gays, lesbians and bisexuals, all queers, trans- and intersexuals" that they are protected in today's Germany.