A 22-year-old Syrian man on Monday confessed to planning an attack in Berlin after becoming radicalized online.

On the first day of his trial at the Moabit Criminal Court in the German capital, the defendant said he was “lucky” to have been caught before committing an attack.

Prosecutors allege the man – who has been in pre-trial detention since November – planned a terrorist attack against Jews and other “non-believers” in Berlin, firstly with a knife and then with a suicide bomb.

The man is charged with a serious act of violence endangering the state, as well as financing terrorism and distributing terrorist material.

He said he had come to Germany at the end of 2023 “to work and earn money.”

However, he was subsequently radicalized on internet platforms such as TikTok, researching martyrdom and viewing publications linked to the Islamic State terrorist group online.

“The devil was in my head,” said the defendant. “I got my ideas from [Islamic State.]”

He is also said to have sought information on building an explosive device and discussed a possible attack in online chats with unknown criminals.

The young Syrian allegedly purchased a knife and several items online suitable for constructing an explosive and incendiary device.

“He was on the verge of building an explosive device,” the indictment read. According to the investigation, the defendant had already begun initial experimental attempts, believing that by carrying out an attack he would have “cleansed himself of his sins” and been revered as an Islamist martyr.

Four further days of hearings are scheduled for the trial until June 5.