Some 8,000 opponents and supporters of German Chancellor Angela Merkel's immigration policy marched through the eastern city of Chemnitz after a wave of racist violence that followed a knife killing.

Thousands of opponents and supporters of German Chancellor Angela Merkel's immigration policy marched through the eastern city of Chemnitz after a wave of racist violence that followed a knife killing, reports said on Saturday.

The rallies, which drew 8,000 people according to police, ended peacefully although there was palpable tension at times during the evening.

Far-right protesters paraded with large portraits of victims of attacks perpetrated, they claimed, by asylum-seekers.

Some chanted "Merkel must go" and "We are the people" while waving German flags.

Anti-fascist demonstrators, meanwhile, brandished banners reading "Chemnitz is neither grey nor brown" and "Heart instead of hate".

There was a heavy police presence with reinforcements from all over Germany after they were outnumbered by thousands of neo-Nazis, football hooligans and other extremists earlier this week.

Sunday and Monday evenings saw outbreaks of street violence, triggered by the arrest of one Iraqi protester and one Syrian, suspected of stabbing a 35-year-old carpenter to death.

Following the arrests, mobs launched random street attacks against people they took to be foreigners, including an Afghan, a Syrian and a Bulgarian man.

Saturday's protests drew around 4,500 far-right supporters from various movements including the far-right anti-immigration alternative for Germany (AfD) party and the anti-Islam PEGIDA movement, according to police estimates.

Another 3,500 marched in support of Merkel's immigration policy, which has seen more than one million migrants and refugees allowed into Germany since 2015.

The government lent its support to the pro-migrant rally through Foreign Minister Heiko Maas who tweeted: "The Second World War started 79 years ago. Germany caused unimaginable suffering in Europe. If once again people are parading today in the streets making Nazi salutes, our past history forces us to resolutely defend democracy."

"We will not let right-wing extremists destroy our country and our democracy. Neither in Chemnitz, nor in Saxony nor anywhere in Germany. Our constitution must prevail. We must defend it. Now!" added one of the Greens' leaders Cem Ozdemir in a tweet accompanied by a picture of him with demonstrators.

The violence and heated debate on immigration have brought back to the fore what has become the most challenging political issue for Merkel, especially in the former communist east of Germany where the AfD is the number one party in some towns and regions.

Following criticism of Merkel's earlier open door policy, her government has increasingly tightened asylum laws as conservative and far-right disquiet has grown.

After an initially jubilant welcome, the migrant influx sparked a strong backlash that saw a spate of hate crimes and swept once-fringe party AfD into parliament.