An Afghan youth has been arrested on suspicion he was a tacit accomplice to the shooting in Munich.

An Afghan youth who was arrested on Sunday had been in contact via WhatsApp with an 18-year-old gunman who killed nine people in Munich two days earlier and also met him just before the attack, Bavarian officials said.

The youth, who was questioned after he contacted police after the shooting, is under investigation for possibly having failed to report the plans of the gunman.

Thomas Steinkraus-Koch, senior public prosecutor in Munich, told a news conference on Monday the Afghan,16, had been in contact with the gunman via WhatsApp until shortly before the attack. He wiped the conversation, but officials were able to retrieve it.

"This (WhatsApp) chat and questioning of a suspect has shown that the Afghan met the gunman directly before the gun attack at what was later the scene of the crime," Steinkraus-Koch told a news conference in Munich.

The shooting was one of four attacks in Germany - three of them by migrants - since July 18 that have left 10 people dead and 34 injured, a toll that may heighten public disquiet over Chancellor Angela Merkel's open-door refugee policy.

More than a million migrants have entered Germany over the past year, many fleeing war in Afghanistan, Syria and Iraq.

The WhatsApp chat showed the Afghan knew the German-Iranian gunman was in possession of a Glock 17 firearm, Steinkraus-Koch said.

"They got to know each other last summer, in 2015, in a psychiatric clinic where they underwent treatment," he said.

"There, it also became apparent to the (Afghan) suspect that the attacker was interested in Breivik," Steinkraus-Koch added, referring to Anders Breivik, who killed 77 people in back-to-back attacks in Norway in 2011.

The Afghan's decision to delete his WhatsApp chat with the gunman and their meeting just before the Munich attack led investigators to suspect he knew of the planned shooting in advance.