On February 19, a far-right extremist went on a shooting spree in the German city of Hanau, targeting customers at two separate shisha lounges.

He killed nine people and injured five others. Every victim of the attack had a migrant background.

It was soon revealed that the 43-year-old assailant, named Tobias R, left behind a series of rambling texts and videos in which he advocated white supremacist views and called for genocide. German authorities said the attacker showed signs of a "deeply racist mentality".

The apparent white-supremacist motivations behind the attack did not come as a surprise to anyone who has been watching the rapid mainstreaming of racist views and ideologies in Germany.

Indeed, since the rise of the far-right, anti-immigrant and anti-Muslim Alternative for Germany (AfD) party to prominence in the 2017 general election, the racist claim that Germany is facing a "Muslim invasion" and that political elites are refusing to take action to stop this has moved from far-right fringes to the political mainstream.

Seemingly centre-right politicians who felt threatened by the increasing popularity of the AfD started to pander to these anti-immigrant, Islamophobic views for political gain, allowing far-right narratives to dominate political discussions.

This empowered racist individuals to become more vocal and take action to facilitate the rebirth of Germany as an ethnically homogenous, "white" nation.

Despite the AfD's attempts to paint the Hanau shootings as a one-off tragedy perpetrated by a mentally unstable individual, the attack was the direct result of German society's growing acceptance of racist, discriminatory and exclusionist views. Prior to last week's tragedy, Germany witnessed a string of similar attacks, including the assassination of pro-immigration German politician Walter Luebcke by a far-right sympathiser in June last year and the deadly shooting that took place outside a synagogue in the eastern city of Halle in October.

It is, however, not too late to reverse this worrying trend. Germany can still be a multicultural success story where immigrants, refugees and asylum seekers from around the world live in harmony with the "native" population. But to achieve this, the German authorities need to treat the Hanau attack as a wakeup call and fundamentally change their attitudes towards the far right.

Recognising past failures, listening to concerned voices

In the aftermath of the attack, prominent German politicians were quick to acknowledge and denounce the racist motivations behind it.

German Chancellor Angela Merkel said, "Racism is a poison ... and is responsible for too many crimes in this country." President Frank-Walter Steinmeier, meanwhile, expressed his grief and added that he stands by "all people who are threatened by racist hatred" in Germany.

The German leadership's admission that the attack was not a stand-alone act by a mentally ill person is a step in the right direction. Nevertheless, if Germany wants to make amends with its migrant populations and make them trust the German state authorities again, they need to take a step further and acknowledge that their past failures have contributed to the situation.

Indeed, the attack in Hanau did not come out of the blue. Migrant organisations, NGOs, and perhaps most importantly, politicians of migrant backgrounds, such as the Green Party's Cem Ozdemir and the Social Democratic Party's Sawsan Chebli repeatedly warned the German authorities of the growing threat of far-right terrorism in Germany.

The German leadership should admit that these warnings fell on deaf ears and promise to listen to the concerns of targeted groups in the future. Sincere apologies coming from people in positions of power will undoubtedly help migrant and minority communities heal, nevertheless, these communities can only start truly feeling at home again in Germany if they know that their leaders are listening to their concerns and taking appropriate action.

Law and Order for, not against, the immigrant population

To put a stop to the mainstreaming of racism in Germany and prevent attacks like the one we witnessed in Hanau, the German authorities also need to re-evaluate their anti-crime policies. For too long, German politicians have been promoting policies that feed into the far-right narratives that cast all Muslim immigrants as outlaws who overwhelmingly participate in organised crime.

For example, in January last year, more than 1,300 police officers were deployed in coordinated raids targeting "family crime clans of Arabic background" in the state of North Rhine-Westphalia. Police spokesman Oliver Peiler told reporters that the raids were targeting shisha bars, particularly because such establishments often "act as sanctuaries for members of these family clans". The state's Minister of the Interior, Herbert Reul, then doubled down on the claim, saying, "Shisha bars are the grounds of clan criminality."

There is no doubt that some criminal gangs establish shisha bars and some criminals visit these establishments regularly. But criminals also run and visit coffee houses, night clubs, restaurants and shops.

By singling out shisha bars, which are overwhelmingly enjoyed by members of Muslim migrant communities, as "grounds of clan criminality" German politicians and security forces contribute to far-right prejudices. It is not far-fetched to assume Tobias R was influenced by these portrayals of shisha bars as he chose the target of his attack.

Criminal gangs harm everyone living in Germany, including immigrant communities. The German state has a responsibility to establish law and order in the country, but it needs to do so without criminalising thousands of innocent people and pandering to racist tropes.

Stop mimicking the far right

These days in Germany the political centre is rapidly accomodating the far-right. The AfD is not only growing in popularity, but also making centrist parties and politicians who are scared of losing votes start promoting aggressively anti-immigrant, and even racist, policies. Heated debates on immigration and integration are benefiting the far-right.

This, however, does not need to be the case.

Centrist parties can listen to the concerns of the German population about immigration without adopting far-right narratives and policies. They did this in 1993 when they introduced new criteria for political asylum claims in the country, known as the "Asylum Compromise". The compromise helped reassure the public that Germany's immigration policies were not being abused without putting genuine asylum claimants in harm's way. With this compromise, centrist parties succeeded in ending the growing influence of the far-right National Democratic Party of Germany (NPD) without moving their programmes further towards the far-right fringes and managed to stop the radicalisation of political debates.

Centrist political parties can repeat this move today. Immigrants and minorities are more active in politics in Germany than they had ever been. With their participation, Germany can draw an inclusive and progressive immigration policy that would also address the "native" population's concerns about immigration - a compromise that embraces both (conservative) "native" and immigrant perspectives without delving into partisan or ethnic tribalism.

What politicians need to do is not parrot far-right narratives to protect their vote share but present an acceptable way forward for all Germans, while reminding the German society of the ills of racism, xenophobia and ethnic hatred. If not, further bitterness between the "natives" and the immigrants in the form of ethnic and racist polarisation would likely unfold.

The views expressed in this article are the author's own and do not necessarily reflect Al Jazeera's editorial stance.