Special police securing the area at Stachus hotel after a shootout in Munich, Germany, 22 July 2016.

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.

Latest news

Greece's creditors want sweeping reforms before next bailout payment

Greece must make sweeping reforms to its labour market, pension system and collective bargaining agreements in order to receive its next vital bailout payment, the country's European creditors said Monday.

President wants to recall "politically appointed ambassadors", can't do it without gov't

President Kolinda Grabar-Kitarovic said that many politically appointed Croatian ambassadors were not carrying out state policies but that she could not replace them without the government to appoint career diplomats who would fight for Croatia's interests.

Izetbegovic hopes ICJ will confirm Serbia's responsibility for genocide

The Bosniak member of the tripartite presidency of Bosnia and Herzegovina, Bakir Izetbegovic, on Monday rejected criticism stirred up by the announcement that the International Court of Justice (ICJ) would be requested to review its judgement made after Bosnia sued Serbia for genocide.

British lawmakers locked in heated debate over Trump's state visit

Allowing US President Donald Trump to visit Britain would be akin to "pimping out the Queen," one British lawmaker said Monday during a heated debate in British parliament over two petitions concerning the US leader's future state visit.

Vitaly Churkin, Russia's sharp-tongued ambassador to the UN, dies

Russia's long-time ambassador to the United Nations, Vitaly Churkin, died in New York on Monday, following a career that spanned four decades and saw Russia emerge from the Soviet Union and experience many turbulent events in its relations with the West.

French police raid National Front over European Parliament payments

France's far-right National Front Monday said that investigators had searched its offices in relation to allegations that it misused European Parliament funds.

Unhappy Presidents' Day: Trump still manoeuvring after Sweden comment

Donald Trump used his first Presidents' Day in office to continue trying to talk his way out of comments implying a terrorist attack in Sweden that never happened.

Croatia supports Kosovo's territorial integrity - Grabar-Kitarovic

Croatia's President Kolinda Grabar-Kitarovic on Monday expressed the support to Kosovo's territorial integrity and Euro-Atlantic aspirations during her talks with the visiting Kosovo Foreign Minister Enver Hoxhaj.

Petrov rules out early parliamentary election

Parliament Speaker and Bridge party leader Bozo Petrov on Monday dismissed speculation about a reshuffle of the parliamentary majority, saying an early election was likelier, but that right now he did not see "such a scenario."

First local elections in 20 years to be held in Nepal on May 14

Nepal's government announced the dates for forthcoming local elections on Monday, nearly 20 years after polls were last held for municipalities and village councils in the country.

US Defence Secretary: We are not in Iraq to seize Iraqi oil

US Defence Secretary Jim Mattis said on Monday that the United States does not intend to seize Iraqi oil, in reference to comments made by President Donald Trump last month.

Bryan Adams to play Zagreb

Canadian rock star Bryan Adams, who has sold more than 100 million albums in his 40-year-long career, will perform in Zagreb on November 9, according to his website and Facebook account.