German investigators looking into Friday's mass shooting in Munich revealed on Sunday the gunman had spent more than a year preparing his attack.
The 18-year-old shooter, identified only as David S., visited the site of a previous school shooting in the German town of Winnenden and took photographs, Bavarian investigator Robert Heimberger said.
He said the shooter, 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."
He also received inpatient psychiatric treatment in 2015 for two months, spokesman for the Munich prosecutor's office Thomas Steinkraus-Koch told reporters. "The suspect had fears of contact with others" and depression, the spokesman said.
Steinkraus-Koch added there was no evidence of any political motivation to the crime, nor that the shooter killed specific victims.
Information from witnesses indicated that his hatred of foreigners might have played a role in the mass shooting, even though he himself was the German-born son of Iranian asylum-seekers.
Most of the dead were youths and all were Munich residents of varied ethnic backgrounds. Hueseyin Bayri, who witnessed one boy's death, told The Associated Press the shooter screamed a profanity about foreigners and said "I will kill you all" as he pulled the trigger. A video shot of the perpetrator also showed him yelling anti-foreigner slurs.
The gunman, a high-school student from Munich with Iranian and German citizenship, also wounded more than two dozen others Friday night before turning his illegal Glock 17 pistol on himself.
Police told reporters that a search of the red backpack lying next to his black-clad corpse revealed that the shooter was carrying more than 300 rounds for the 9-millimeter handgun he used to kill his victims.
The filed-off serial numbers of the Glock made it difficult to establish its origin. But investigators said the gunman, identified by German officials only as David S., had no permit to carry it.
One victim was 45, another 20 and the rest were between 14 and 19, Munich police chief Hubertus Andrae said. The fact that most of the dead were so young added to what Chancellor Angela Merkel called "an evening and night of horror."
It started as a normal Friday evening. A Munich mall was buzzing with shoppers, and across the street, customers were enjoying a meal at a McDonald's restaurant.
Earlier that day, the shooter hacked a Facebook account and sent a message inviting people to come to the mall for a giveaway, said Robert Heimberger, the head of Bavaria's criminal police.
Investigators say they are still looking for a motive for the attack but Munich prosecutor Thomas Steinkraus-Koch noted the gunman apparently was undergoing psychiatric treatment for problems including depression. Interior Minister Thomas de Maiziere said authorities were checking reports the teen may have been bullied by his peers.
Witnesses and a dramatic cell-phone video that police think is genuine indicated the gunman was unstable and disliked foreigners.
The shooter yelled anti-foreigner slurs both at a person verbally sparring with him from a balcony, which was caught on film by a neighbor, and later also inside the mall.
At another point, he yells, "I'm German!" to which the man on the balcony, identified by the Bild newspaper as Thomas Salbey, a 57-year-old construction worker, responds, "You are a jerk!" and demands to know what he is up to, saying "you should be in psychiatric care." The gunman orders the filming to stop, and shortly after that starts shooting, causing the neighbor filming to duck.
Police did not offer details on the ethnicities of the victims. But Kosovo Foreign Minister Enver Hoxhaj said two were Kosovo Albanians after arriving in Munich on Saturday evening to "express my condolences to the families, relatives and friends."
Law enforcement officials think the Munich tragedy could be a copy-cat attack, considering it was carried out on the fifth anniversary of the killing of 77 people by Norwegian right-wing extremist Anders Behring Breivik, whose victims included dozens of young people.
A search of the shooter's home overnight revealed a trove of literature about mass killings, including a German-language translation of the English book "Why Kids Kill: Inside the Minds of School Shooters."
De Maiziere said the shooter had researched a 2009 school shooting in Germany as well as the Breivik attack.
"There was material found in the apartment of the suspect that showed a particular interest in shooting sprees," de Maiziere said.
But there was no evidence that he was linked to extremist groups such as the Islamic State, law enforcement officials told reporters, adding they believe the gunman acted alone.
Merkel called a special meeting Saturday of her government's security Cabinet and pledged afterward that Germany would "do everything possible to protect the security and freedom of all people," saying that, in the wake of a train attack near Wuerzburg and the truck attack in Nice, she understood Germans are wondering "Where is safe?"
"Such an evening and such a night is difficult to bear," she said of the Munich attack. "And it's even more difficult to bear because we have had so much terrible news in so few days."
Munich residents described scenes of chaos and panic as the shooting unfolded and bystanders ran for cover.
"I was standing on the balcony smoking a cigarette. Suddenly I heard shots," said Ferdinand Bozorgzad, who lives in a high-rise building next to the Olympic Shopping Center mall. "First I thought someone had thrown some firecrackers. I looked down at the McDonald..s and saw someone shooting into the crowd. Then I saw two people lying there. "
Franco Augustini, another resident, said his daughter hid in the mall during the attack.
"Next to our flat was a woman who was full of blood," Augustini said. "My wife had a bottle of water. Then we helped to wash her. It was horrible and made me speechless."
Some 2,300 police from across Germany and neighboring Austria were scrambled in response to the attack. It was the second targeting victims apparently at random in less than a week in Bavaria. On Monday, a 17-year-old Afghan asylum-seeker wounded five people in an ax-and-knife rampage near Wuerzburg, for which ISIS claimed responsibility.
Despite the shooter having no apparent Islamic extremist links, Muslims in Germany were already fearing a backlash.
"I started to get texts from friends asking if I was safe," said Iranian David Akhavan, who works in a Persian restaurant in Munich. "Then, my thoughts were: Please, don't be a Muslim. Please don't be Middle Eastern. Please don't be Afghan. I don't accept any of this violence."
Munich's mayor, Dieter Reiter, declared a day of mourning for the victims.
"These are difficult hours for Munich," he said, adding that residents had shown great solidarity toward each other. "Our city stands united."
The Associated Press contributed to this report.