MUNICH (AP) -- The gunman whose rampage at a Munich mall left nine people dead was a depression-plagued teenager who avidly read books and articles about mass killings and apparently tried to lure young victims to their deaths through a faked Facebook posting, authorities said Saturday.

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 18-year-old 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, ending a shooting rampage that could have become even more tragic.

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 group, 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 the Islamic State group has 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."

---

Frank Jordans and David Rising in Berlin, Colleen Barry in Milan and Kirsten Grieshaber in Dusseldorf contributed to this story.