Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

German Chancellor Angela Merkel on Thursday condemned the deadly shootings in the city of Hanau the night before, saying they exposed the "poison" of racism in German society.

Merkel spoke in Berlin on Thursday morning, hours after a gunman killed 10 people and injured several others in two separate attacks outside hookah lounges before fatally shooting himself in his home.

"There are many indications at the moment that the perpetrator acted on right-wing extremist, racist motives, out of hatred toward people of other origins, religion or appearance," she said.

"Racism is poison, hatred is poison and this poison exists in society, and it is to blame for too many crimes."

Merkel pledged to fight against those who try to divide the country along ethnic lines.

Download the NBC News app for breaking news

The gunman, 43, was identified by authorities as only Tobias R., in accordance with German privacy laws.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

The victims were 21 to 44 years old, and Germany's federal prosecutor, Peter Frank, said all nine were of foreign backgrounds. Turkey's ambassador said five were Turkish citizens, according to the AP. Frank said six people were injured, one seriously.

The gunman first attacked a hookah bar in central Hanau — a city close to Frankfurt — at about 10 p.m. Wednesday local time (6 p.m. ET), killing several people before heading about a mile and a half miles west and opening fire again, claiming more victims.

At hookah bars, patrons smoke flavored tobacco from water pipes, popular in the Middle East.

Forensic police at a crime scene in the center of Hanau, near Frankfurt am Main, Germany, on Thursday, Feb. 20, 2020. Thomas Lohnes / AFP - Getty Images

Witnesses and surveillance videos of the suspect's getaway car led authorities quickly to his home, near the scene of the second attack, where he was found dead near his 72-year-old mother, who had also been shot dead, said Peter Beuth, the interior minister for the state of Hesse, according to The Associated Press.

"Initial analysis of the web page of the suspect indicate a xenophobic motivation," Beuth said. It did not appear, however, that the suspect was known either to police or Germany's domestic intelligence agency, he added.

One witness, Kadir Kose, ran over from a cafe he runs nearby after he heard the first shots, initially assuming there was an altercation between family members.

"But when I heard the second shots I thought it was a terror attack," Kose told the AP.

He said he was shocked at the extent of the violence, saying that while fights or stabbing aren't unheard of, "this is a whole other level, something we hear about from America."

Hanau's federal MP, Katja Leikert, called the attack a "horrific scenario" in a tweet in which she offered her "heartfelt condolences" to the victims.

"We expect German authorities to show maximum effort to enlighten this case. Racism is a collective cancer," Ibrahim Kalin, special adviser to President Recep Tayyip Erdoğan of Turkey, said earlier on Twitter.

Germany is home to 3 million people of Turkish origin, including a million ethnic Kurds.

The incident comes as Germany is on high alert over concerns about the rise of the far-right groups. Germany's far-right party Alternative for Germany (AfD) has disrupted the final stages of Merkel's four-term chancellorship.

In October, a deadly gun attack on a synagogue in the eastern city of Halle on Yom Kippur underscored the rising threat of neo-Nazi violence. The attack, in which two people were killed, was streamed live.

Last June, conservative politician Walter Luebcke — an advocate of a liberal refugee policy — was shot at his home.