You are not permitted to download, save or email this image. Visit image gallery to purchase the image.
The presumed attacker - a 43-year-old German man identified as Tobias R. - was found dead near a gun soon after the shootings late on Wednesday (local time) in Hanau, near Frankfurt, authorities said.
The victims included German citizens and foreigners aged between 21 and 44, the federal prosecutor 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 as 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 killed a number of people in one bar in downtown Hanau before driving 2.5km to a second bar in town and killing more, police said.
Officers chased a car leaving the scene of the last shooting to another address, where the found the bodies of the suspect and his 72-year-old mother, both with gunshot wounds.
"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," Public Prosecutor General Peter Frank said.
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.
"We expect German authorities to show maximum effort to enlighten this case. Racism is a collective cancer," Turkish presidency spokesman Ibrahim Kalin said on Twitter.
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".
Immigration and a slowing economy has helped build support for radical groups at both ends of the political spectrum in Germany, which is home to three million people of Turkish origin including one million ethnic Kurds.
Merkel, whose 2015 decision to welcome almost one million asylum seekers fuelled 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 last year, an anti-Semitic gunman opened fire outside a German synagogue on Yom Kippur, the holiest day of the Jewish year, and killed two people as he livestreamed his attack.
At one of the bars on Thursday morning, forensics police in white overalls inspected the crime scene, cordoned off close to Hanau's historic market place.
Can-Luca Frisenna, whose father and brother run one of the two bars attacked, said he rushed there after hearing about the shooting.
"I heard my father was affected and my little brother, they run the kiosk," he said. "They were horrified and they were crying and everything. So everyone was shocked."
European Commission President Ursula von der Leyen, who is German, said she was deeply shocked and mourned with the families and friends of the victims.