German police arrested a 16-year-old Afghan youth on suspicion of a connection to the killing of nine people by an 18-year-old gunman in Munich, authorities said.
The youth is under investigation for possibly having failed to report the plans of the gunman, who later shot himself, and may have played a role in a Facebook posting that invited people to a meeting near the Munich train station, a police statement said.
"There is a suspicion that the 16-year-old is a possible tacit accomplice to (Friday's) attack," it said.
The 18-year-old German-Iranian gunman who killed nine people in Munich on Friday began planning the attack a year ago after visiting the German city of Winnenden where another teenager killed 15 people in 2009, Bavarian officials said.
Materials found at the gunman's home also showed he had been hospitalised for psychiatric care for three months around the same time, and was an avid player of violent video games, the officials told a news conference.
One of the games was 'Counter Strike: Source', Robert Heimberger, president of the state crime office, said.
He said it was "a game played by nearly every known rampage killer".
The gunman - identified as David Sonboly (below) - called himself 'Ali' and once described the 17-year-old killer in the 2009 attack as a good person, according to a 16-year-old youth with whom he played video games in an online club, the German magazine Spiegel reported.
He frequently used online video handles such as 'Hate' and 'Rampage Killer', expressed nationalistic views, and was eventually excluded from the club because the other members were afraid of him, the magazine cited the other youth as saying.
The gunman was also evidently inspired by Norwegian mass killer Anders Breivik, and likely deliberately staged the shooting on the fifth anniversary of Breivik's massacre of 77 people, Mr Heimberger said.
Bavaria's chief prosecutor Thomas Steinhaus-Koch said the gunman was treated for anxiety and had been hospitalised for psychiatric treatment from July to September 2015, followed by out-patient treatment as recently as last month.
Investigators also found prescription medicines at his home, where he lived with his parents and younger brother.
He had made reference to his hospitalisation in a heated exchange that was videotaped immediately after the shooting.
"I am German," he yelled at a bystander in a nearby apartment house after he yelled a racial slur and threw a beer bottle. "Because of you I was bullied for seven years."
Officials said authorities had investigated allegations in 2012 that the gunman was bullied by three other children, but none of those individuals - or any other classmates of the gunman - were among the shooting victims.
Nor did the victims include anyone who commented on a fake Facebook page created by the gunman in May, using photographs and the name of a young Turkish woman, the officials said. He had invited people to free food at the McDonald's restaurant at 4pm local time, shortly before the shooting began.
Mr Heimberger said the gunman likely purchased his weapon - a reactivated Glock 17 pistol - on the shadowy ‘dark net’ area of the internet.
He said it was unclear when he bought the gun, or how he paid for it, adding that the parents of the gunman remained in shock and were not able to be interviewed.