Berlin: A friend of the Munich shooter, an Afghan teen, may have known in advance of the attack in which nine people were gunned down, prosecutors said Monday.
The 16-year-old Afghan refugee, who has not been named, met with the shooter at the scene of the attack shortly before he launched his rampage, prosecutors said.
An 18-year-old Iranian-German named in German media as Ali David Sonboly killed nine people at a suburban McDonald's restaurant and a nearby shopping centre, before turning the gun on himself.
Chief Munich prosecutor Thomas Steinkraus-Koch told a press conference that they had become aware of the meeting between the gunman and the Afghan after police recovered a WhatsApp message exchange between the two.
The Afghan had deleted the messages from his mobile phone.
Investigators believe that the 16-year-old, who was arrested on Sunday night, knew that the gunman had a weapon before the two-hour-long shooting spree.
The authorities said that the shooter's friend would face a charge of not reporting a crime after providing a series of contradictory answers to them.
But police released the Afghan youth from custody later Monday after a judge rejected the arrest warrant, a spokesman for the prosecutor's office said. The judge said there were no strong suspicions or grounds to hold him.
The authorities were working on the assumption that because the Afghan teen was present at the scene of the shooting and given his possible knowledge of the weapon used in the attack "that he might have known something about the crime."
Police said the attack was inspired by other mass shootings around the world rather than radical Islamist groups such as Islamic State.
Investigators say that both the gunman and his friend were fixated on violent computer games.
"My impression was that (he carried out the shootings) like he was in a computer game," said Munich criminal police director Hermann Utz on Monday.
He shot his victims in execution-style killings.
The Afghan teen had left the shopping centre by the time the shooting spree had started.
Prosecutors say that the 16-year-old met the Munich gunman, who had been suffering from depression, about one year ago when the two received psychiatric treatment.
It was during their time in treatment that the young Afghan heard about the gunman's fascination with mass shootings, notably the Norwegian far-right terrorist Anders Behring Breivik, who is serving a 21-year jail term for his rampage five years ago, which left 77 dead.
The gunman told him during their treatment that he had a hatred for people, prosecutors said.
Police said the gunman carried out his attack with a Glock 17 caliber 9 millimeter pistol.
He acquired the gun via the darknet, a computer network that is a source of illegal goods and weapons and which requires special software to gain access.
A Glock pistol has also been used by others involved in other mass shootings, including Breivik.
Bavarian police have also launched an investigation into people posting Facebook invitations to a fast-food restaurant in the town of Regensburg, which were similar to the ones posted by the Munich shooter to lure his victims.
Police say they now have a presence in the shopping centre and are in contact with its management.
They have also warned that anyone seeking to copy the Facebook post involved in the Munich attack would be committing an offence.