A suspected far-right extremist carried out the attacks on two shisha bars in western Germany, killing at least nine people, officials say.
Chancellor Angela Merkel said there were many signs the attacker in the city of Hanau had acted out of racism.
Federal prosecutors are treating the case as terrorism. Some of those killed were believed to be of Turkish origin.
The 43-year-old suspect killed himself, police say. He was found dead at his home along with the body of his mother.
Local media have identified the suspect as Tobias R, a German citizen. The Bild tabloid reports he had a firearms licence, and that ammunition and gun magazines were found in his car.
Authorities are examining a video that appears to be from the suspect, posted online days before the attacks, in which he expresses right-wing conspiracy theories. Bild said he had also left a letter of confession.
The attack comes amid growing concerns about far-right violence in Germany. Speaking in Berlin, Mrs Merkel said: “Racism is a poison. Hate is a poison and this poison exists in our society and is already to blame for many crimes.”
The shootings took place around 22:00 (21:00 GMT) on Wednesday, and the first target was the Midnight shisha bar in the city centre of Hanau. Witnesses reported hearing about a dozen gunshots.
The suspect then reportedly travelled in a dark car to the Kesselstadt neighbourhood and opened fire at the Arena Bar & Cafe.
Shisha bars are places where people gather to smoke a pipe known as shisha or hookah. Traditionally found in Middle Eastern and Asian countries they are also popular in many other parts of the world.
Some of those killed were of Turkish origin, Turkish presidential spokesman Ibrahim Kalin tweeted. Calling for a full German investigation, he said: “Racism is a collective cancer.”
The shootings sparked a seven-hour manhunt, while officers searched for what they thought could have been more than one attacker. Police identified the gunman through information from witnesses and surveillance cameras.
Early on Thursday, they stormed the suspect’s home, near the scene of the second shooting, where he was found dead near his 72-year-old mother.
Can-Luca Frisenna, whose father and brother run one of the two bars attacked, told Reuters news agency: “I heard my father was affected and my little brother… I saw them both – they were horrified and they were crying and everything. So everyone was shocked.”
Hanau, in Hesse state, is a city of 100,000 residents about 25km (15 miles) east of Frankfurt.
Hesse Interior Minister Peter Beuth said authorities were also examining a website attributed to the suspect. “What we know so far is that there is definitely a xenophobic motive. Whether there are claims of responsibility or documents, that’s still being investigated,” he said.
Mrs Merkel also vowed to do everything possible to clarify the background to the attack, saying: “There are many indications at the moment that the perpetrator acted on right-wing extremist, racist motives, out of hatred towards people of other origins, religion or appearance.”
Gun laws in Germany are among the most stringent in the world, and were tightened further in recent years after other mass shootings.
Hanau Mayor Claus Kaminsky told Bild it had been a “terrible night”, adding: “You could not imagine a worse night. It will of course keep us busy for a long, long time and remain a sad memory. I’m deeply moved.”
Katja Leikert, who represents Hanau in the German parliament, the Bundestag, said: “Hopefully the injured recover swiftly. It is a horrific scenario for us all.”
In other reactions: