This is an archived article and the information in the article may be outdated. Please look at the time stamp on the story to see when it was last updated.

The gunman who killed nine people in a rampage in Munich on Friday was obsessed with mass shootings and appeared to have planned the attack for a year, officials said.

“He appears to have planned this act since last summer,” Robert Heimberger, president of the Bavarian state criminal police office, said at a press conference Sunday.

“He completely occupied himself with this act of rampage.”

Police have not named the attacker. They said he was an 18-year-old with dual German and Iranian nationality who was born and raised in Munich. Neighbors told CNN Saturday that a teen named Ali Sonboly lived in an apartment searched by police, the same name reported by German media outlets.

On Sunday, a 16-year-old Afghan believed to have been a friend of the attacker was arrested on “suspicion of being an accessory,” Munich police said.

Police said Saturday the attacker was a mentally troubled individual who extensively researched rampage killings, and had no apparent links to terror groups and no political motive.

On Sunday, investigators revealed he left behind a long written statement on his computer, which was still being analyzed. They said they found photographs on his camera showing he visited the German town of Winnenden, the site of a deadly 2009 school shooting.

Earlier, officials said they found in the gunman’s belongings numerous documents on mass killings, including a book entitled “Rampage in My Mind — Why Students Kill.”

Officials believe there likely was significance in the timing of the attack, which came five years to the day since Anders Behring Breivik killed 77 people in Norway in 2011, many of them attendees at a youth camp.

Gunman had received psychiatric treatment

The gunman had also been under psychiatric care in a hospital for two months in 2015, officials said Sunday.

Documents found in his home confirmed that he suffered from mental illness, including depression and anxiety, Munich prosecutor Thomas Steinkraus-Koch said Sunday.

Police found medication in his home and are trying to determine whether he had been taking it. the shooter had a history of having been bullied by his peers, and in 2012 had been injured in an attack by other young people that had been reported to police.

A search of his belongings revealed he was also an avid player of first-person shooter video games, including “Counter-Strike,” officials said Sunday.

People lured to attack site

The deadly attack began in a McDonald’s outside Munich’s Olympia mall on Friday evening, bringing Germany’s third-largest city to a standstill before the gunman was found dead of a self-inflicted gunshot wound.

The rampage also left 35 people injured, 10 of them seriously, officials said.

The shooter used a fake Facebook account to lure people to the McDonald’s by offering free food, police said Sunday. Earlier, they said he may have hacked another person’s account, but they clarified on Sunday that it was an entirely fake account set up in another person’s name.

Police are investigating whether the attacker’s friend who was arrested was aware of the Facebook post or if he had prior knowledge of the attack and failed to notify police. The 16-year-old was interviewed based on his relationship with the suspect and gave conflicting statements, Munich police said.

Heimberger said the attacker appeared to have illegally purchased the pistol used — a 9 mm Glock 17 — through the “dark web,” a shadowy part of the Internet that is not discoverable by standard search engines and is used for anonymous, illicit transactions.

Police believed it was an older weapon that had been reassembled, and were still working to establish where the attacker had obtained the 300 rounds of ammunition found in his rucksack.

Victims mostly teenagers

Most of the victims in Munich in their teens: Three victims were 14 years old, two were 15, one was 17 and one was 19. A 20-year-old and a 45-year-old were also killed.

The victims were all German nationals from the Munich area, officials said. Turkey’s Foreign Ministry said three of the victims were also Turkish nationals.

Another of the victims was also a Greek citizen, Greece’s Foreign Ministry said Saturday.

The shooting shook Europe after a spate of recent terror attacks on the continent, including the stabbing of passengers on a German train by a man who claimed to be inspired by ISIS and the killing of 84 people in a truck attack in Nice, France.