The 18-year-old German-Iranian who killed nine people at a shopping mall in Munich last week before turning the gun on himself was a racist who may have targeted people with immigrant backgrounds, investigators told the German media on Wednesday.

Ali David Sonboly, who was born to Iranian parents in the south-east town of Munich, killed nine people, all of them with immigrant backgrounds and six of them aged between 14 and 17.

Sonboly had a “feeling of superiority” towards Arabs and Turks, and considered it a “distinction” that he was born on 20 April - the birthday of Adolf Hitler - sources close to the investigation told German newspaper Frankfurter Allgemeine Zeitung (FAZ) on Wednesday.

People who knew Sonboly have told investigators that he was proud of his “Aryan” heritage – Iran is considered in Nazi ideology to be the birthplace of the Aryan race.

He used an unlicensed weapon bought from the Dark Web to launch the attack at a shopping mall in Munich last Friday.

Sonboly had brought at least 300 bullets with him, so would have been able to kill or wound many more people had he wanted to.

Investigators are now probing whether he deliberately targeted certain people - seven of his victims were Muslims, and four were of Turkish origin.

Another friend of the teenager – who fled the scene after the shooting and was later found shot in the head around a kilometre away – told Der Spiegel that Sonboly had “harboured tremendous hatred for most foreigners”.

He had reportedly forbidden friends from referring to him using the name Ali, saying that he did not want to be mistaken for a Muslim.

Sonboly played computer games under the usernames “Hate” and “Gunman,” and posted a message saying that “Turkey = ISIS,” Der Spiegel reported.

He also told other players that he supported Alternativ fur Deutschland (AfD), the far-right populist party currently polling at over 10 percent.

A 15-year-old fellow player who had been in contact with Sonboly was arrested in southern Germany on Tuesday on suspicion of planning a similar attack on his school.

Police discovered “a large number of small-calibre cartridges, several knives and daggers, evacuation plans for his school and a large quantity of chemicals, materials and instructions for making explosives,” during a search, officials said on Wednesday evening.

The boy has been taken to a youth psychiatric facility.

He reportedly told police that he had at one point planned an attack on his school because of problems in his personal life, but had changed his mind.