A Syrian with suspected links to the Islamic State group who blew himself up outside a German music festival was in contact with another person “who influenced the attack” immediately beforehand, authorities said Wednesday.

The 27-year-old failed asylum seeker, who wounded 15 people at a nearby cafe late Sunday when he was refused access to the festival venue, had been speaking to an unknown person in an “intensive” online chat, Bavaria state interior minister Joachim Herrmann said.

“Apparently he had direct contact with someone who had significant influence on the way the attack played out,” Herrmann said on the sidelines of a state government meeting.

“The chat ended immediately before the attack.”

Herrmann said it was not immediately clear whether the unknown person had contact with IS jihadists, where the chat participant was, or how long the two had been in contact.

The minister revealed on Monday that the attacker had made a video pledging allegiance to IS leader Abu Bakr al-Baghdadi that was found on his smartphone.

IS later said via the militant-linked Amaq news agency that the attacker “was a soldier of the Islamic State”.

The assailant also had longstanding links to al Qaeda, the IS online weekly Al-Naba said Wednesday.

Originally from the city of Aleppo in northern Syria, he joined Al-Qaeda in Iraq before returning to his country to try to infiltrate the intelligence services of President Bashar al Assad.

When war broke out in 2011, he formed an armed cell to launch roadside bomb attacks on regime forces and later joined Al-Nusra Front, the al Qaeda affiliate in Syria.

He was wounded in Aleppo and left the country for treatment in Europe, where he followed the actions of IS in Syria and Iraq while planning a large-scale attack of his own in Germany, Al-Naba said.

According to German authorities, the assailant travelled to Germany two years ago but had his asylum claim rejected after a year because he had already been granted refugee status in Bulgaria.

He had tried to kill himself twice in the past and had spent time in a psychiatric clinic, authorities said.

Herrmann said that the attacker had large amounts of cash on him and stashed in his room — unusual for an asylum seeker.

Meanwhile, a psychological evaluation of the assailant written in 2015 found that it was possible that he would commit “suicide in a spectacular way”, noting that after the death of his wife and six-month-old son he had “nothing left to lose”.

It was not clear when or how his family members died.

The Federal Office for Migration and Refugees (BAMF) confirmed the written assessment, first reported by the daily Bild, and said that he had at first not been deported because of his acute mental instability.

But after he did not respond to official requests for information, the BAMF ordered him to leave Germany this month.

Germany was already reeling after nine people were killed in a shopping centre shooting spree in Munich on Friday and four passengers on a train and a passer-by were wounded in an axe attack in Wuerzburg on July 18.

IS also claimed the axe rampage.

All three brutal incidents were in Bavaria, the southern state which has been a portal for scores of thousands of refugees under Chancellor Angela Merkel’s liberal asylum policy.

In northern Germany, police on Wednesday raided a mosque in the town of Hildesheim, seen as a meeting point for radical Islamists, Lower Saxony state said in a statement cited by German news agency DPA.

Officials also raided the apartments of eight members of the German Islam Conference (DIK) association that ran the mosque, the statement said.

“The DIK is a hotbed of radical Salafism,” the state’s interior minister Boris Pistorius said, referring to an ultra-conservative movement of Sunni Islam.

During prayers and seminars held at the mosque, calls for “hate against the disbelievers” had been made, Pistorius said.