The presumed attacker - a 43-year-old German man identified as Tobias R. - was found dead close to a gun soon after the shootings late on Wednesday in Hanau, near Frankfurt, authorities said.
At least five of the victims were Turkish nationals, Ankara’s ambassador to Berlin told state broadcaster TRT Haber as his government demanded robust action.
Chancellor Angela Merkel condemned the “poison” of racism. Her deputy, Olaf Scholz, took to Twitter to say: “Politically, nobody can deny that 75 years after the Nazi dictatorship there is real terror again”.
The gunman burst into in a bar in downtown Hanau then drove to a second bar in town and opened fire again, police and witnesses said.
“First we heard five or six rounds of gunfire,” a German-Turkish survivor who gave his name as Muhammed told Reuters from his hospital bed in Hanau.
“Then I saw the man entering. I was eating my meal at that time. We were all eating. We gave orders. The man entered,” he said, sobbing.
“We were 10 to 12 people. Two, three or four people managed to survive. I am one of them.”
Officers chased a car leaving the scene of the last shooting to another address, where they found the bodies of the suspect and his 72-year-old mother, both with gunshot wounds, police said.
“On the suspected perpetrator’s home page, he had put up video messages and a kind of manifesto that, in addition to obscure thoughts and absurd conspiracy theories, pointed to deeply racist views,” said Prosecutor General Peter Frank.
Frank told reporters the nine people shot dead had immigrant backgrounds. His office later said they included German citizens and foreigners aged between 21 and 44. Six more people were injured in the attack, one seriously.
Thousands of people gathered for candlelight vigils in about 50 German cities on Thursday evening. In Hanau, President Frank-Walter Steinmeier told crowds that Germans and foreigners should unite to defeat racism.
“We are mourning, we are taking part in vigils and we see that we are united both in our mourning and against racism and violence,” Steinmeier said after laying a wreath outside one of the shisha bars.
The Confederation of the Communities of Kurdistan in Germany said several victims were Kurdish and accused Germany’s political leaders of “not resolutely opposing right-wing networks and right-wing terrorism”.
Germany is home to three million people of Turkish origin including one million ethnic Kurds.
Bulgarian public broadcaster BNT said a 32-year-old Bulgarian man was among the victims.
Merkel, whose decision to welcome almost one million asylum seekers in 2015 contributed to the rise of the far-right Alternative for Germany (AfD) party, told reporters: “Racism is poison, hatred is poison and this poison exists in society and it is to blame for too many crimes.”
In October, an anti-Semitic gunman opened fire outside a German synagogue on Yom Kippur, the holiest day of the Jewish year, and in a kebab restaurant in the eastern city of Halle, killing two people as he livestreamed his attacks.
In June, a far-right sympathizer was accused of shooting dead a pro-immigration politician. Last week police detained 12 men suspected of setting up a far-right organization with the goal of carrying out attacks against politicians, asylum seekers and Muslims.
More about: #Germany