A 16-year-old Afghan friend of the Munich mall attacker who killed nine people in a rampage before killing himself may have known of the attack in advance, police revealed Monday.

Officers said they arrested and later released him, but still were investigating him for not reporting what he may have known about the planned attack.

Police said they caught the unnamed teen late Sunday and investigators were able to retrieve a deleted chat between him and the German-Iranian attacker on the messaging app WhatsApp.

Based on the chat, it appeared the 16-year-old met with the 18-year-old attacker at the mall before the rampage, and knew the attacker had a pistol, police added. The rampage left dozens of people wounded.

Investigators say the two teenagers met last year as in-patients at a psychiatric ward. Both were being treated for online game addiction, among other things.

Four major attacks have rocked Germany in about a week, at least three linked to refugees.

In Munich on Sunday evening, some 1,500 people gathered at the scene of the shooting there, lighting candles and placing flowers in tribute to the victims. Police said the gunman had planned the attack for a year.

In southern Germany on Sunday, a failed asylum-seeker from Syria blew himself up and wounded 15 people after being turned away from an open-air music festival, investigators said.

Earlier Sunday, a Syrian man killed a woman with a machete and wounded two others outside a bus station in the southwestern city of Reutlingen before being arrested. Police said there were no indications pointing to terrorism and the attacker and the woman worked together in the same restaurant. Polish authorities said she was a Polish citizen.

And an ax attack on a train near Wuerzburg last Monday wounded five. A 17-year-old Afghan asylum-seeker was shot and killed by police as he ran from the scene. The Islamic State terror group claimed responsibility for that attack.

The Associated Press contributed to this report.