Frank-Walter Steinmeier spoke on 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.

Steinmeier blasted remarks by one of the leaders of the far-right AfD party seen as playing down the importance of the Nazi period and the Holocaust.

Alexander Gauland of the Alternative for Germany (AfD) party, the biggest opposition party in the Bundestag lower house of parliament, sparked outrage at the weekend with a speech saying there was more to the country's history than the 12 years of the Nazi regime.

"Yes, we plead guilty to our responsibility for the 12 years" of Nazi rule, he said.

AAP

But "we have a glorious history and one, my dear friends, that lasted a lot longer than those damned 12 years," Gauland said.

"Hitler and the Nazis are just a speck of bird shit in over 1,000 years of successful German history."

Leading a chorus of condemnations, Steinmeier said that anyone "who denies that singular break with civilisation or minimises it not only ridicules the victims but also wants to rip open old wounds and sow new hatred".

"We must all stand against this," he said.

Gauland, whose party has more than 90 seats in the Bundestag, received an enthusiastic round of applause for his speech before his party's youth wing.

He has repeatedly attacked Islam and argued that Germany should be proud of its veterans of two world wars.

In 2016, he took aim at star footballer Jerome Boateng, who was born in Berlin to a German mother and a Ghanaian father.

"People find him good as a footballer, but they don't want to have a Boateng as a neighbour," Gauland said.

The general secretary of Angela Merkel's conservative Christian Democratic Union party, Annegret Kramp-Karrenbauer, quickly hit out at Gauland's latest remarks on Saturday, saying that the AfD was revealing its true face.

"50 million war victims, the Holocaust and the total war are nothing more than 'bird shit' for the AfD," she tweeted. "That's what the party really looks like behind its bourgeois mask."

Set up in 2013 as an anti-euro party, the AfD recorded a surge in support after it began capitalising on unease in Germany over the arrival of more than a million asylum seekers since 2015.