A gunman killed nine people in two apparently racially motivated shootings at shisha bars in the German town of Hanau, police said. The suspect then killed himself, according to officers, after also killing his mother at his home.

Investigators believed a racist motive was behind the attack, said Peter Beuth, the interior minister for the state of Hessen. Angela Merkel said the circumstances of the attack needed to be fully investigated, and the shootings had exposed the “poison” of racism in German society. She pledged to stand up against those who sought to divide the country.

Nine people died in the attacks on the two bars on Wednesday night. Five others had life-threatening injuries, police said.

Some of those killed were of Turkish origin, a spokesman for the Turkish presidency said. “We expect German authorities to show maximum effort to enlighten this case. Racism is a collective cancer,” İbrahim Kalın tweeted.

The killer was named by police as 43-year-old Tobias R. His surname was not given, in line with German practice. German media named him as Tobias Rathjen.

Screengrab shows suspect Tobias R, 43, taken from an account purportedly belonging to him, which has now been removed from the site. Photograph: Getty Images

He shot himself and his 72-year-old mother at home, police said. They also confirmed he possessed a hunting licence.

The Bild newspaper said the gunman had expressed extreme rightwing views in a letter of confession he left behind. A video in which he explained his motives is believed to be part of the investigation. The Guardian could not confirm the details of his confession. The video was taken down from social media sites on Thursday morning, police said.

After the murders, a huge hunt was launched for the perpetrator involving dozens of armed police and a helicopter hovering above the commuter town 15 miles (25km) east of Frankfurt.

Police tweeted at about 5am local time that special police force officers had stormed the home of the alleged suspect and found him dead along with another body.

“There are currently no indications of other perpetrators,” police said in a statement.

Footage shows aftermath of deadly shisha bar attacks in Germany – video

Officers sealed off and searched the terrace house in Hanau’s Kesselstadt district, near the scene of one of the shootings, after following up witness statements on a getaway car.

According to local media, eight or nine shots were fired at the Midnight shisha bar on Heumarkt in the centre of the town at about 10pm. A dark vehicle was seen leaving the scene. Soon afterwards, shots were fired at a second shisha bar – the Arena Bar and Café in Kurt-Schumacher-Platz in the western Kesselstadt district.

Police denied initial reports of a third incident in the district of Lamboy.

They urged any witnesses with mobile phone footage to upload it to a police website, and appealed to them not to post the evidence on social media.

Michael Malkmus,a spokesman for Hessen police force, said local people helped the police track down the alleged perpetrator after seeing his car parked on the street. “We came to the building after calls from people who had seen a vehicle. We ID’d his number plate and matched it to his home. We sealed the area and then entered the home.”

Neighbours reported hearing a huge bang as police used explosives to break down the door at 3am.

Show more

Federal prosecutors said on Thursday they were taking charge of investigating the shooting amid reports that the suspect may have had a far-right motive.

Merkel pledged that “everything will be done to investigate the circumstances of these terrible murders”.

She added: “Racism is a poison. Hatred is a poison. This hatred exists in our society and its is responsible for far too many crimes.”

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.

The mayor of the town, Claus Kaminsky, said it was the “worst evening imaginable”. Hanau has a population of about 100,000.

Germany attack: gunman acted on rightwing, racist motives, says Merkel – video

Last Friday one person was shot dead and four were injured outside a Berlin music venue. The shooting occurred near the Tempodrome, which was hosting a Turkish comedy show. The motives behind the Berlin attack have remained unclear.

Witnesses to the Hanau attack described how the gunman randomly fired shots into the bars. One witness, Kenan Kocak, said he was waiting to hear whether his uncle, who had been in the bar, had survived. “I do not know whether he has pulled through,” he told the TV station NTV. “It’s very sad in particular that young people – a young lad, and a young girl about 20, 25 years old – have died. I was there with them yesterday. Someone who worked there was also taken to hospital. It looks very bad.”

One man in his early 30s said he received a call from a friend who had been in one of the bars. “He left a message to tell me he had been hit,” the man, who was not identified, told NTV. “I called him back immediately. He told me he was in an ambulance. He had a bullet in his shoulder.”

Another witness who knew some of the victims said: “These are people we have known for years. It’s like in a film. That it’s happened is unimaginable. That there are people out there who are so heartless, shooting others who have done nothing wrong.”

Other witnesses spoke of finding empty bullet casings strewn on the ground outside one of the cafes.