The gunman who went on a shooting rampage in Munich killing nine people had spent more than a year preparing his attack.

Bavarian investigator Robert Heimberger said the 18-year-old German-Iranian named in reports as Ali Sonboly visited the site of a previous school shooting in the German town of Winnenden and took photographs.

He said the attacker, who likely got his illegal weapon through the internet's "dark net" market, was an avid player of first-person shooter video games, including "Counter-Strike: Source."

Thomas Steinkraus-Koch, spokesman for Munich prosecutor's office said there is still no evidence of any political motivation for the crime, nor that the shooter killed specific victims when he opened fire at a shopping centre and a McDonald's on Friday.

It was also revealed that the gunman had received two months' inpatient psychiatric treatment last year.

Thomas Steinkraus-Koch, a spokesman for Munich prosecutors' office, said the gunman "received inpatient treatment in 2015 for two months and after that received outpatient care."

"The suspect had fears of contact with others" and also depression.

The gunman took his own life following the attack in which 27 people were injured - 10 of whom are in a critical condition, including a 13-year-old boy.

Sign up to our free newsletters

Get the best updates straight to your inbox:
Please select at least one mailing list.

You can unsubscribe at any time by clicking the link in the footer of our emails. We use Mailchimp as our marketing platform. By subscribing, you acknowledge that your information will be transferred to Mailchimp for processing.